Created
December 19, 2012 17:02
-
-
Save ericf/4338310 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
| var app = new Y.App(); | |
| app.notify = function (req, res, next) { | |
| if (!this._route_evt) { | |
| this._route_evt = this.publish('route', { | |
| defaultFn: function () { | |
| next(); | |
| } | |
| }); | |
| } | |
| this.fire('route', { | |
| req: req, | |
| res: res | |
| }); | |
| }; | |
| app.route('/', 'notify', function (req, res, next) { | |
| var view = new Y.View(); | |
| view.get('container').setText('HOME!'); | |
| this.showView(view); | |
| }); | |
| app.route('/about', 'notify', function (req, res, next) { | |
| var view = new Y.View(); | |
| view.get('container').setText('About!'); | |
| this.showView(view); | |
| }); | |
| app.on('navigate', function (e) { | |
| Y.log('navigating!'); | |
| }); | |
| app.on('route', function (e) { | |
| Y.log('routing!'); | |
| if (e.req.url === '/about') { | |
| // Don't let the user go to "/about", for some reason. | |
| e.preventDefault(); | |
| } | |
| }); | |
| app.render().navigate('/'); | |
| // => "navigating!" | |
| // => "routing!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment