Last active
December 23, 2015 22:39
-
-
Save dvdsmpsn/6704414 to your computer and use it in GitHub Desktop.
Adding custom JavaScript events to your add-ons in Atlassian products
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
// This approach allows you to decouple code much better. The event and the event handler can be completely separated. | |
// See also: http://mattryall.net/blog/2010/05/improving-javascript-code-with-custom-events | |
// event handling function | |
var someCustomBehaviour = function () { | |
AJS.log(' +++ event triggered: my-custom-event'); | |
} | |
... | |
... | |
// bind the event to some function | |
AJS.bind('my-custom-event', someCustomBehaviour); | |
... | |
... | |
// trigger the event at some stage | |
AJS.trigger('my-custom-event'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment