add.widget - Events - Author API

Author API Events

add:widget

Fires when an author clicks on the "Add new" button on the Item edit page.

You would want to be notified about this event firing, because you might want to enforce a maximum number of widgets in a particular column of the Item before more can be added, for example.

Use event.preventDefault() to block adding widgets and prevent unexpected behavior.

Examples

// Standard usage to listen to the add:widget event
authorApp.on('add:widget', function (event) {
    console.log('This code executes when the author clicks on the "Add new" button.');
    console.log(event.data);
    console.log(event);
});

// Example to prevent adding more widgets
authorApp.on('add:widget', function (event) {
    if (shouldNotAddMoreWidgets) {
        event.preventDefault();
    }
});

Callback arguments

  • region_id string

    The ID of the column in the user interface of the Item editor where the widget has been added.

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.