on
on Method
Description
The on method can be called to install event handlers for various Web SDK
events. When an event handler is installed, the function you provide as the handler will
be called when the specified event occurs.
.on(/*String*/ eventName, /*Function*/ handler)
Parameters
eventName String
The name of an editor event. See the events topic for more information.
handler Function
A function that will be called each time the event occurs in the editor. The signature of this handler function depends on the event name. See events for more information.
Note that most events have only one handler active at a time. These events always have a default handler. Defining a handler for these events will always replace the current handler.
Returns
An object containing the method remove that can be called to remove the custom event handler. For events with only one
active handler, calling this method will restore default handler for the event.
Example
var commandEnableHandler = editor.on('commandEnable',
function (/*String*/ commandId, /*Boolean*/ enabled) {
// summary:
// Invoked when the enabled state of a command changes
// commandId: String or Array of Strings
// CommandId(s) which have changed their enabled state
// enabled: Boolean
// The enabled state of the command
// returns: nothing
...
}
);
...
// Remove the command enable handler.
commandEnableHandler.remove();
Web SDK Developer’s Guide