Module: util/hooks

Hook system to modify simple things.
Source:
See:
  • Events for hook events
Example

Accessing the hook system

window.rml.hooks.register("yourAction", function() {
 // Do something
});

Quick reference

Methods

(inner) call(name, args, context) → {module:util/hooks}

Call an event.
Parameters:
Name Type Description
name string The event name
args Array.<mixed> Pass arguments to the callbacks
context object Pass context to the callbacks
Source:
Returns:
Type
module:util/hooks

(inner) exists(name) → {boolean}

Checks if a event name is registered.
Parameters:
Name Type Description
name string The event name
Source:
Returns:
Type
boolean

(inner) register(names, callback) → {module:util/hooks}

Registers a callback to a given event name.
Parameters:
Name Type Description
names string The event name, you can also pass multiple names when splitted with " "
callback function The callback function with the arguments
Source:
Returns:
Type
module:util/hooks

(inner) register(name, callback) → {module:util/hooks}

Deregister a callback to a given event name.
Parameters:
Name Type Description
name string The event name
callback function The callback function with the arguments
Source:
Returns:
Type
module:util/hooks

Events

attachment/relocate

An attachment is relocated and should be saved to the server.
This:
  • wp.media.view.AttachmentsBrowser
Parameters:
Name Type Description
folder module:store/TreeNode~TreeNode The tree node
attachmentId int The attachment id
nextId int The next id
lastIdInView int
next jQuery
Source:

attachmentsBrowser/collection/change

Fired when the collection of attachments browser changes.
This:
  • wp.media.view.AttachmentsBrowser
Parameters:
Name Type Description
appTree object The app tree instance
Source:

attachmentsBrowser/item/removed

Fired when an attachments browser item gets removed.
This:
  • wp.media.view.AttachmentsBrowser
Parameters:
Name Type Description
args... mixed The event arguments
Source:

attachmentsBrowser/item/rendered

Fired when an attachments browser item is rendered.
This:
  • wp.media.view.Attachment.Library
Parameters:
Name Type Description
$el jQuery The element
model object The backbone model
appTree object The app tree instance
Source:

attachmentsBrowser/modal

Fired, when a new modal window is created.
This:
  • wp.media.view.AttachmentsBrowser
Source:

attachmentsBrowser/modal/dom/ready

A modal attachments browser is created and the view for the React element is ready.
This:
  • wp.media.view.AttachmentsBrowser
Parameters:
Name Type Description
container object The backbone view
Source:

folder/meta

The MetaBox ref element is ready and created.
Parameters:
Name Type Description
ref HTMLElement The reference
id string | id The folder id or 'usersettings'
store module:store~Store The store
Source:

folder/meta/saved

The MetaBox is saved successfully.
Parameters:
Name Type Description
id string | id The folder id or 'usersettings'
response object The server response
data object The data sent to the server
Source:

folder/meta/serialize

The MetaBox is serialized and ready to send.
Parameters:
Name Type Description
id string | id The folder id or 'usersettings'
store module:store~Store The store
data object The data prepared for the server so you can perhaps modify it
form HTMLElement The form container
Source:

general

General event when script for RML is ready to load.
Source:

ready

General event when DOM is ready and a list table / grid mode is available in media library page.
Source:

rest/button/error/$url

Fired when a button with class .rml-rest-button is successfully saved.
This:
  • jQuery
Parameters:
Name Type Description
args... mixed The $.ajax success arguments
method string The method
data object The data
Source:

rest/button/prepare/$url

Fired when a button with class .rml-rest-button gets clicked and the POST data is prepared so you can modify it. The $url is the data-url attribute of the button. You also have to define a data-method attribute.
This:
  • jQuery
Parameters:
Name Type Description
data object The data
Source:

rest/button/success/$url

Fired when a button with class .rml-rest-button is successfully saved.
This:
  • jQuery
Parameters:
Name Type Description
args... mixed The $.ajax success arguments
method string The method
data object The data
Source:

shortcode/dialog/insert

The shortcode gets generated. You are able to modify the shortcut depending on the modal data.
Parameters:
Name Type Description
shortcodeData object
Properties
Name Type Description
shortcode object The shortcode which you can modify
data object The data from the dialog
Source:

shortcode/dialog/open

The shortcode dialog gets opened. You can modify the fields.
Parameters:
Name Type Description
options object The options
editor object The editor instance
Source:

tree/init

The React AppTree instance gets constructed and you can modify it here.
This:
Parameters:
Name Type Description
state object
props object
Source:

tree/node

A tree node is fetched from the server and should be prepared for the module:store/TreeNode~TreeNode class.
Parameters:
Name Type Description
node object The node object
Source:

uploader/add

A new file is added.
This:
  • object
Parameters:
Name Type Description
file object The file
folder module:store/TreeNode~TreeNode The folder node
store module:store~Store The store
Source:

uploader/init

The uploader gets initialized.
This:
  • wp.Uploader
Source:

wprfc/$function

A RML WP RFC is called and should be handled.
Parameters:
Name Type Description
data object The element data
$el jQuery The element
Source:
Listeners of This Event: