Manual Trigger events

The Trigger feature in the Greyd Plugin allows Trigger Events to be manually triggered. See the Trigger Filters documentation for more details about the PHP filters.

Use the following method to manually trigger a trigger event via JavaScript:

JavaScript
/**
 * Trigger a custom greyd-trigger Event.
 * 
 * Function renamed from 'greyd_trigger.trigger()' to 'greyd.trigger.trigger()'
 * so the themes greyd_trigger function is deprecated.
 * 
 * @param {Event} event		original event containing the target element
 * @param {string} string	name of the trigger
 * @param {bool} isGlobal	trigger globally
 */
greyd.trigger.trigger(event, name, isGlobal);

Internally, this function dispatches a jQuery event on <body> which can be listened for by other scripts:

JavaScript
$("body").trigger("greyd-trigger", [event, name, isGlobal]);

Blocks that should respond to a trigger must include the following data attribute:

HTML
data-greyd-trigger="your-trigger-name"

If a block should start hidden, it also needs:

HTML
data-onload="hide"

This system gives you full control over when and how blocks appear, helping you build rich interactive UI elements directly in the block editor.

Last updated: