Public Method Author API

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

  • eventName string

    Name of the event that you want to listen to.

  • eventCallback eventCallback

    Callback function that will be invoked whenever the event is fired.

  • context object

    Execution context that will be used for this when the calback function is invoked.

Return value

AuthorApp

Returns 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.
Was this article helpful?