Created
August 25, 2012 12:40
-
-
Save drale2k/3465027 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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