Skip to content

Instantly share code, notes, and snippets.

@urre
Created December 18, 2013 07:41
Show Gist options
  • Save urre/8018681 to your computer and use it in GitHub Desktop.
Save urre/8018681 to your computer and use it in GitHub Desktop.
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