Skip to content

Instantly share code, notes, and snippets.

@dvdsmpsn
Last active December 23, 2015 22:39
Show Gist options
  • Save dvdsmpsn/6704414 to your computer and use it in GitHub Desktop.
Save dvdsmpsn/6704414 to your computer and use it in GitHub Desktop.
Adding custom JavaScript events to your add-ons in Atlassian products
// 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