Permalink
Browse files

added add new Graph

  • Loading branch information...
1 parent 1ac95f2 commit 1da53bec99334555cd481a4b8c82f1c4a26cceea @philfree committed Jul 16, 2012
Showing with 14 additions and 3 deletions.
  1. +1 −0 .meteor/packages
  2. +1 −1 client/gauge.html
  3. +12 −2 client/gauge.js
View
@@ -5,3 +5,4 @@
d3
backbone
+jquery
View
@@ -32,5 +32,5 @@ <h1>this is an other page ??</h1>
</template>
<template name="add_graph">
-<input type="text" class="add_graph"> <input type="submit" value="Add Graph">
+<input type="text" class="add_graph" id="new-graph"> <input type="button" class="add" value="Add Graph">
</template>
View
@@ -4,7 +4,6 @@ Circles = new Meteor.Collection("circles");
console.log("Audrey test");
-
if (Meteor.is_client) {
Template.gauge.drawsomething = function () {
@@ -54,7 +53,7 @@ if (Meteor.is_client) {
console.log("You clicked!");
draw_circle(event.layerX, event.layerY);
Circles.insert({
- graph_id: Session.get('graph_id'),
+ graph_id: Session.get('selected_graph'),
cx: event.layerX,
cy: event.layerY }) ;
}
@@ -78,6 +77,17 @@ if (Meteor.is_client) {
Router.setGraph(this._id);
}
};
+
+ Template.add_graph.events = {
+ 'click input.add': function () {
+ var text = jQuery('#new-graph').val();
+ var id = Graphs.insert({name: text});
+ Router.setGraph(id);
+ Session.set("selected_graph", id);
+ jQuery('#new-graph').val('');
+ }
+ };
+
Template.graph_list.selected = function () {
return Session.equals("selected_graph", this._id) ? "selected" : '';
};

0 comments on commit 1da53be

Please sign in to comment.