Share via


Sys.EventHandlerList.removeHandler Method

Removes an event handler from an event in an EventHandlerList instance.

var e = new EventHandlerList();
e.addHandler(id, handler);
e.removeHandler(id, handler);

Arguments

  • id
    The ID for the event.

  • handler
    The handler to remove from the event.

Remarks

Use the removeHandler method to remove an event handler from an event defined in an EventHandlerList object. If the event has only one handler when removeHandler is called, the event will continue to exist as a placeholder in the EventHandlerList instance.

The addHandler and removeHandler methods also enable you to dynamically change an event in a script component at run time. For example, you can remove a handler from the list during its execution so that it runs only the first time the event is raised.

Example

The following example shows how to call the addHandler and removeHandler methods in a custom control. This is part of a larger example found in the EventHandlerList class overview.

// Bind and unbind to click event.
add_click: function(handler) {
    this.get_events().addHandler('click', handler);
},
remove_click: function(handler) {
    this.get_events().removeHandler('click', handler);
},

See Also

Reference

Sys.EventHandlerList Class

Other Resources

Language Reference