Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jeroenr
Created August 31, 2012 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroenr/3554614 to your computer and use it in GitHub Desktop.
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
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