ContentBlocks ContentBlocks 2.x Developer Client Events Layout Events
Table of Contents
Triggered on the Layout instances:
focuswith no data when the layout becomes active. Moving focus between blocks in the same layout does not fire it again. (triggered by Canvas)instanceidwith data{ from, to }when the ID for the layout changed. This happens when first saving the resource (or other canvas) that the layout was added on, and replaces the temporary ID (e.g.new-ext-gen231) with the permanent ID for the layout as saved in the database.addwith no data when a layout is added to the canvas. (triggered by LayoutCollection)changewhen the layout changes. The data depends on what changed:- Title or instance id, from the layout store:
{ valueKey, newValue, oldValue } - A layout setting input:
{ inputKey, valueKey, newValue, oldValue, inputStore } - Lock:
{ inputKey: null, valueKey: "locked", newValue: { locked:true/false }, oldValue: { locked:true/false }, store } - Publishing:
{ inputKey: null, valueKey: "publishing", newValue, oldValue, store }, where the values are{ active, activate_on, deactivate_on } - Move: an empty object, fired after
move. (triggered by LayoutCollection)
- Title or instance id, from the layout store:
beforeRemovewith data{ preventRemove: false }. (triggered by LayoutCollection) The collection checks its own local flag after the event, so changingpreventRemoveon the data object does not cancel the remove.removewith no data when the layout has been removed. (triggered by LayoutCollection)hidewith no data when the layout is collapsed. (triggered by Layout)showwith no data when the layout is expanded again. (triggered by Layout)movewith data{ direction, newIndex }when the layout was moved on the canvas.directionis"up"or"down". (triggered by LayoutCollection)toolbarwith data{ items }when the toolbar is rendered. Update (by reference) the provided items array to add, reorder, or remove toolbar items. Each item is an object with keys:key(unique id),icon(font awesome icon name),text(button text to show),title(hover title),handler(callable to handle clicks),renderer(callable that turns the item into a DOM element). (triggered by LayoutToolbar) Every layout toolbar is re-rendered when any layout is added, changed, or removed.
Slightly more advanced events:
beforeInsertFieldModalwith data{ body, canvas, layout, column }when the modal is prepared to insert a field on this layout. You can change the modal contents before it is opened. The modal markup may change, so be conservative in your targeting. Also triggered on the column and the canvas. (triggered by BlockCollection)beforeInsertLayoutModalwith data{ body, canvas, index, layout }when the modal is opened from this layout’s insert button.layoutis this layout, andindexis its position. Also triggered on the canvas. Opening the modal from the canvas insert button does not fire this on a layout, andlayoutisnullthere. (triggered by LayoutCollection)locked:changewith data{ layout, oldValue, newValue }. Each value is{ locked }.publishing:changewith data{ layout, oldValue, newValue }. Each value is{ active, activate_on, deactivate_on }. The canvas also receiveslayout:publishing:changewith the same data.
Bubbling up from Blocks
block:addwith data{ block, index }when a block is added to the layout.indexis-1when the block is appended. Also fired when a block is moved in from another column. Bubbled from the column.block:changewith data{ block, changeData }when a block in the layout has changed.changeDatais the blockchangepayload:{ inputKey, valueKey, newValue, oldValue, inputStore, store }. Bubbled from the column.block:removewith data{ block }when a block is removed from the layout. Also fired when a block is moved to another column. Reordering a block inside the same column does not fire this. (triggered by BlockCollection, and bubbled from the column)block:toolbarwith data{ block, items }when a block toolbar in the layout is rendered. Bubbled from the column.
Bubbling up from Columns
column:addwith data{ column }when a column is added. (triggered by ColumnCollection)column:changewith data{ column, changeData }when a column fireschange. Core does not currently fire this.column:removeis not currently triggered. Columns are created with the layout and are not removed on their own currently.