Skip to content

Instantly share code, notes, and snippets.

@werelax
Last active December 23, 2015 04:39
Show Gist options
  • Select an option

  • Save werelax/6581484 to your computer and use it in GitHub Desktop.

Select an option

Save werelax/6581484 to your computer and use it in GitHub Desktop.
Backbone Router con "pestañas" (secciones en una misma PageView con rutas distintas)
/* Router */
var AppRouter = R.extend(SmartRouter, {
init: function() {
this._super()
this.hottest()
},
routes: {
"": "index",
"latest": "latest",
"hottest": "hottest",
"post/:id": "detalles"
},
index: function() {
this.hottest()
},
latest: function() {
if (!(this._activePage instanceof PostListPageView)) {
this.changePage(new PostListPageView())
}
this._activePage.showSection("recent")
},
hottest: function() {
if (!(this._activePage instanceof PostListPageView)) {
this.changePage(new PostListPageView())
}
this._activePage.showSection("popular")
},
detalles: function(id) {
this.changePage(new PostDetailsPageView(id))
}
})
/* Init */
window.appRouter = new AppRouter()
Backbone.history.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment