SCEditor

bind()

bind(events, func) Since: 1.4.1

Binds a handler to the specified events.

Unlike the jQuery bind() method, this method only binds a limited set of supported events.

The supported events are:

  • keyup
  • keydown
  • keypress
  • blur
  • focus
  • contextmenu
  • nodechanged
    When the current node containing the selection changes in WYSIWYG mode
  • valuechanged
    Triggered when the editors value changes (this isn’t called after every key press)
  • selectionchanged When the editors selection changes (triggered a lot)
  • pasteraw
  • paste

Syntax

instance.bind(events, func[, excludeWysiwyg][, excludeSource]);

Parameters

events
Type: String

List of events separated by spaces to bind the handler to.

func
Type: Function

Function that will be called when the event occurs

excludeWysiwyg
Type: Boolean
Default: false

If to not bind the handler to the WYSIWYG editor.

excludeSource
Type: Boolean
Default: false

If to not bind the handler to the source editor.

Return

Type: sceditor

Example

var textarea = ...;
sceditor.instance(textarea).bind('keypress', function(e) {
    alert('Key pressed');
});