Skip to content

Instantly share code, notes, and snippets.

@frekw
Created June 1, 2010 19:44
Show Gist options
  • Save frekw/421384 to your computer and use it in GitHub Desktop.
Save frekw/421384 to your computer and use it in GitHub Desktop.
var Controller = {
init: function(){
},
didClickButton: function(event){
var data = "something";
$.event.trigger("data:added", [data]);
}
}
var Model = {
init: function(){
$.bind("data:added", $.proxy(Model, "didAddData");
this.data = [];
},
didAddData: function(data){
this.data.push(data);
// fire an ajax request here or something
}
}
$("a#important-action").click($.proxy(Controller, "didClickButon")); // or fire a custom event if no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment