Last active
December 23, 2015 04:39
-
-
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)
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
| /* 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