Availability: >= 3.0

Type: Object Method

Description: Registers a new button state handler.


$editor->addJSButtonStateHandlerstring $handleridstring $function );

A button state handler is a JavaScript function that controls when a button should be displayed as ready, disabled or latched.

The ID name of a button state handler is used as the last parameter of the registerButton method. 

This function provides a convenient hook into the JavaScript API.


The ID name of the new button state handler. This is used when registering a new button that should be controlled by this handler.

The JavaScript function to control the button state. This could be the name of an existing JavaScript function or the function code itself.


The following example creates a new button that will insert a cite tag and registers a handler for the new button that will display the button as latched when the selection is within a cite tag.

// create a new button and add it to the toolbar:

// register the handler for the new button:
$editor->addJSButtonStateHandler ('citehandler''function (EDITOR,srcElement,cid,inTable,inA,range){
    var c = range.getContainerByTagName("CITE");
    if (c) {
        return "wproLatched";
    } else {
        return "wproReady";