Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

watch for changes on the results panel

  • Loading branch information...
commit dd6f661dd765527253b7504ae6a8f48412e5d8cd 1 parent 2ce3f54
@mjumbewu authored
Showing with 11 additions and 0 deletions.
  1. +9 −0 static/polls/models.js
  2. +2 −0  static/polls/views.js
View
9 static/polls/models.js
@@ -11,6 +11,15 @@ var Polls = Polls || {};
{choice: choiceId},
function(data) { self.set(data); }
);
+ },
+
+ watch: function() {
+ this.fetch();
+ this.timeout = setTimeout(_.bind(this.watch, this), 1000);
+ },
+
+ stopWatching: function() {
+ clearTimeout(this.timeout);
}
});
View
2  static/polls/views.js
@@ -22,10 +22,12 @@ var Polls = Polls || {};
this.hideVoteForm();
this.resultsView.$el.show();
this.resultsView.render();
+ this.model.watch();
},
hideResults: function() {
this.resultsView.$el.hide();
+ this.model.stopWatching();
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.