on()
Set up an event listener for the Author API. This method binds a callback function that will be invoked whenever the specified eventName
is fired.
You would want to use this method so that you can take custom actions in your application when certain defined events occur in the authoring interface.
Examples
// Start listening for the 'render:item' event.
authorApp.on('render:item', function (event) {
console.log('Item rendered.');
});
// Multiple events can be listened to using chained calls.
authorApp
.on('save', function (event) {
console.log('Save complete.');
})
.on('save:error', function (event) {
console.log('There was an error saving. Please try again.');
});
Arguments
Return value
AuthorAppReturns the current instance of Author API if successful.
Related articles
- Author API events
- The
off()
method, which allows you to unbind event listeners. - The
once()
method, which allows you to bind event listeners that execute only once.