Created
December 18, 2013 07:41
-
-
Save urre/8018681 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 MyRouter = Backbone.Router.extend({ | |
| routes: { | |
| "/foo": "foo" | |
| }, | |
| foo: function(){ | |
| myController.doFoo(); | |
| } | |
| }); | |
| var MyView = Backbone.View.extend({ | |
| events: { | |
| "click #foo": "fooClicked" | |
| }, | |
| fooClicked: function(e){ | |
| e.preventDefault(); | |
| this.trigger("do:foo"); | |
| } | |
| }); | |
| var myController = { | |
| doFoo: function(){ | |
| // do stuff here, put the app in to a specific state, show new views, etc. | |
| }, | |
| show: function(){ | |
| var view = new MyView(); | |
| view.on("do:foo", this.doFoo, this); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment