DiviArea.addAction()

DiviArea.addAction(hook, callback, priority, context)

// Alias:
DiviArea.Hooks.addAction(hook, callback, priority, context)

The JS API uses an action/filter system that is very similar to the WordPress actions/filters. The API fires actions at certain points that you can tap into to provide additional functionality.

The addAction() function registers a callback function that is executed when the specified action is fired.

Params

hook string, required
Name of the action to observe.
callback function, required
The callback function to execute when the action is fired. Any return value of the callback function is ignored.
priority int, optional
Used to specify the order, in which callbacks are executed. Callbacks with a lower priority are called first.
Default: 10
context object, optional
Used to define a custom value for the scope-variable this in the callback function.
Default: <code>window</code>

Returns

The function does not return anything.

Examples

DiviArea.addAction('show_area', function() {
  console.log('An Area is displayed');
});

Notes

To see the exact names and execution order of all the JS API actions and filters on your website, simply [enable the Debugging Output], then open your browsers JS console and visit a page with an Area/Popup. Look for the “Apply Filters” and “Do Action” entries:

Sample output in the browsers JS console.
Sample output in the browsers JS console.
Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Get in touch with us