← Toda la documentación

Ejecutar JavaScript en los eventos del editor

Adjunta un controlador de eventos que se ejecuta cuando se produce el evento.

Sintaxis

editor.attachEvent(eventName,eventHandler)

eventName

Type: String

Specifies the name of the event to be called.

eventHandler

Type: function

A function to execute when the event is triggered.

Ejemplo de uso

editor1.attachEvent("exec_command_newdoc", function (state, cmd, value) {
    state.returnValue = true;//handled, don't execute default action
    this.setHTMLCode("<p>New Doc...</p>");
});

editor.detachEvent()

Elimina el controlador de eventos indicado que se registró antes con el método attachEvent.

Sintaxis

editor.detachEvent(eventName,eventHandler)

eventName

Type: String

specifies the name of the event that is listened by the event handler.

eventHandler

Type: function

Reference to the event handler function to remove.