|Manuals

off

Description

Allows you to remove an event handler from a specific node. This method works with both local client-side events and remote server-declared events.

Syntax

JsRO.off(object, event, handler);

Parameters

Parameter Type Description
object String Node path as a string
event String Event name as a string
handler Function Reference to the handler function previously set with on()

Return Value

Type Description
Boolean true if the event was removed successfully, false if it was not

Remarks

The off method removes event handlers that were previously added with the on method. You must provide the same handler function reference that was used when adding the event.

The method supports two types of events:

  • Local events (client-side): Use the model: prefix for local property change events
  • Remote events (server-declared): Use the object path directly for events declared on the server

Examples

Remove Local Event Handler

// Define the handler function
var changeHandler = function(elem) {
    console.log('Checkbox changed');
};

// Add the event handler
JsRO.on('model:Form1.checkBox1', 'changed', changeHandler);

// Later, remove the event handler
JsRO.off('model:Form1.checkBox1', 'changed', changeHandler);

Remove Remote Event Handler

// Define the handler function
var clickHandler = function(elem) {
    console.log('Checkbox clicked');
};

// Add the event handler
JsRO.on('Form1.checkBox1', 'click', clickHandler);

// Later, remove the event handler
JsRO.off('Form1.checkBox1', 'click', clickHandler);

Complete Example

var JsRO = new Thinfinity.JsRO();

// Define handlers
var buttonHandler = function(elem) {
    console.log('Button clicked');
};

// Add handler
JsRO.on('Form1.button1', 'click', buttonHandler);

// Remove handler when no longer needed
document.getElementById('removeHandler').onclick = function() {
    var result = JsRO.off('Form1.button1', 'click', buttonHandler);
    if (result) {
        console.log('Handler removed successfully');
    }
};

See Also