Permalink
Browse files

add a shell for routes

move initialization of the model in to the router
  • Loading branch information...
1 parent a58d8b1 commit 6492bd05cd3d5013a1fb7e3a79d659e64eec4f4d @mjumbewu committed Sep 4, 2012
Showing with 35 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. BIN polls.db
  3. +28 −0 static/polls/routes.js
  4. +6 −2 templates/polls/detail.html
View
@@ -2,3 +2,4 @@
*.pyc
*~
env/
+.env/
View
BIN polls.db
Binary file not shown.
View
@@ -0,0 +1,28 @@
+var Polls = Polls || {};
+
+(function(P, $) {
+
+ P.Workflow = Backbone.Router.extend({
+ initialize: function(options) {
+ this.results = new P.Results(options.initialResults);
+ this.results.url = options.resultsUrl;
+
+ // Create the app views
+ },
+
+ routes: {
+ '/polls/:id/': 'showPoll',
+ '/polls/:id/results/': 'showResults'
+ },
+
+ showPoll: function(id) {
+ // Tell the app view to show the poll form
+ },
+
+ showResults: function(id) {
+ // Tell the app view to show the results
+ }
+
+ });
+
+})(Polls, jQuery);
@@ -12,8 +12,12 @@
</form>
<script>
- results = new Polls.Results({{ initial_results_data|default:'{}'|safe }});
- results.url = '{% url polls_api_results poll.id %}';
+ workflow = new Polls.Workflow({
+ resultsUrl: '{% url polls_api_results poll.id %}',
+ initialResults: {{ initial_results_data|default:'{}'|safe }}
+ });
+
+ Backbone.history.start({pushState: true});
</script>
{% endblock %}

0 comments on commit 6492bd0

Please sign in to comment.