Created
June 13, 2011 10:25
-
-
Save fwielstra/1022573 to your computer and use it in GitHub Desktop.
The same application in Backbone.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
window.ThreadController = Backbone.Controller.extend({ | |
initialize: function() { | |
this.threadListModel = new ThreadListModel; | |
this.threadListView = new ThreadListView; | |
Backbone.history.start(); | |
}, | |
routes: { | |
"/" : "listThreads" | |
}, | |
listThreads: function(query) { | |
this.threadListModel.fetch(); | |
}, | |
}); | |
window.ThreadListView = Backbone.View.extend({ | |
el: $("#main"), | |
initialize: function(threads) { | |
_bindAll(this, 'render'); | |
}, | |
render: function() { | |
$(this.el).html(ich.threadTemplate(this.model.toJSON())); | |
} | |
}); | |
window.ThreadListModel = Backbone.Model.extend({ | |
url : 'thread'; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
on line number 20 it should be "_.bindAll(this, 'render');