Skip to content

Instantly share code, notes, and snippets.

@drale2k
Created August 25, 2012 12:40
Show Gist options
  • Save drale2k/3465027 to your computer and use it in GitHub Desktop.
Save drale2k/3465027 to your computer and use it in GitHub Desktop.
# THIS WORKS
# Videos Router
class Etaxi.Routers.Videos extends Backbone.Router
routes:
'' : 'videos'
'videos' : 'videos'
initialize: ->
@collection = new Etaxi.Collections.Videos()
@collection.fetch()
videos: ->
view = new Etaxi.Views.VideosIndex(collection: @collection, router: this)
$('#wrapper').append(view.render().el)
console.log window.a = view
# Videos View
class Etaxi.Views.VideosIndex extends Backbone.View
template: JST['videos/index']
tagName: "section"
id: "content-videos"
className: "content inner"
initialize: ->
@collection.on('reset', @render, this)
render: ->
$(@el).html(@template())
this
# THIS NOT
# News Router
class Etaxi.Routers.News extends Backbone.Router
routes:
'news' : 'news'
initialize: ->
@collection = new Etaxi.Collections.News()
@collection.fetch()
news: ->
view = new Etaxi.Views.NewsIndex(collection: @collection, router: this)
$('#wrapper').append(view.render().el)
# News View
class Etaxi.Views.NewsIndex extends Backbone.View
template: JST['news/index']
tagName: "section"
id: "content-news"
className: "content inner"
initialize: ->
@collection.on('reset', @render, this)
render: ->
$(@el).html(@template())
this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment