GutenBricks Events for Gutenberg Editor
Since v1.1
GutenBricks blocks triggers custom events when blocks are loaded. These events are useful if you want to run custom JavaScript within Gutenberg Editor.
These events are only available in Gutenberg Editor and NOT frontend.
gb:block:init
This event is triggered when the block is rendered and initialized with all the editing features. This is when your custom JavaScripts should run.
gb:block:removed
Triggered when the block is removed from the editor. You can use this to clean up.
gb:block:prerendered
Triggered when the block content is rendered once in the editor. This content doesn't have editing features instantiated yet. Because it is prerender, the DOM elements are deleted after gb:block:init. It is useful, when you want to add custom loading animation.
Dynamic Data For Events
GutenBricks provides dynamic data built for events. These events are triggered when a specific block loads, removes and prerenders (meaning renders static block without editing features.) You can use these dynamic events to run JavaScript functions for any blocks inside the Gutenberg editor.
GutenBricks Event: Block Load
Triggered when a block is fully loaded with editing features. In normal circumstances, this is the default event to use.
GutenBricks Event: Block Remove
Triggered when a block is removed from the document DOM. You can use this to clean up JavaScript instances to free up the memory and avoid side effects.
GutenBricks Event: Block Prerender
Triggered when the static block is rendered. The static DOM elements lasts very shortly. So we recommend you not to use this to modify element DOMs. Instead you can use it to pre-load any important functions for the block.
What's inside event.detail
clientId
A unique ID for the block
domElement
The dom element of the block rendered
block
GutenBricks block object
Last updated