-
-
Save mxriverlynn/439c4b042c312636bd2d to your computer and use it in GitHub Desktop.
how an event becomes a command
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
| $(".edit-button").on("click", (e) => { | |
| someThing.doSomeWork(); | |
| }); |
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 EmployeeView = Marionette.ItemView.extend({ | |
| // ... | |
| events: { | |
| "click .edit-button": "editClicked" | |
| }, | |
| editClicked: function(e){ | |
| // ... now what? | |
| } | |
| }); |
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 EmployeeView = Marionette.ItemView.extend({ | |
| // ... | |
| events: { | |
| "click .edit-button": "editClicked" | |
| }, | |
| editClicked: function(e){ | |
| // mimic the DOM event | |
| this.trigger("click"); | |
| } | |
| }); |
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 EmployeeView = Marionette.ItemView.extend({ | |
| // ... | |
| events: { | |
| "click .edit-button": "editClicked" | |
| }, | |
| editClicked: function(e){ | |
| // trigger an event with more meaning | |
| this.trigger("edit"); | |
| } | |
| }); |
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 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