Skip to content

Instantly share code, notes, and snippets.

@mxriverlynn
Last active September 4, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxriverlynn/439c4b042c312636bd2d to your computer and use it in GitHub Desktop.
Save mxriverlynn/439c4b042c312636bd2d to your computer and use it in GitHub Desktop.
how an event becomes a command
$(".edit-button").on("click", (e) => {
someThing.doSomeWork();
});
var EmployeeView = Marionette.ItemView.extend({
// ...
events: {
"click .edit-button": "editClicked"
},
editClicked: function(e){
// ... now what?
}
});
var EmployeeView = Marionette.ItemView.extend({
// ...
events: {
"click .edit-button": "editClicked"
},
editClicked: function(e){
// mimic the DOM event
this.trigger("click");
}
});
var EmployeeView = Marionette.ItemView.extend({
// ...
events: {
"click .edit-button": "editClicked"
},
editClicked: function(e){
// trigger an event with more meaning
this.trigger("edit");
}
});
var EmployeeView = Marionette.ItemView.extend({
// ...
events: {
"click .edit-button": "editClicked"
},
initialize: function(options){
this.managementView = options.managementView;
}
editClicked: function(e){
// call the object directly
this.managementView.show();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment