Created
August 31, 2012 15:28
-
-
Save jeroenr/3554614 to your computer and use it in GitHub Desktop.
Fetch JSON from server based on backbone model URL and render backbone view
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
class Blog.Routers.PostsRouter extends Backbone.Router | |
routes: | |
"posts/:page" : "index" | |
".*" : "index" | |
index: (page) -> | |
pageNumber = page || 1 | |
@posts = new Blog.Collections.PostsCollection() | |
@view = new Blog.Views.Posts.IndexView({model:@posts, page:parseInt(pageNumber)+1}) | |
@accommodations.fetch({data: {page: pageNumber}}) | |
$("#posts").html(@view.render().el) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment