event

attaches an event handler to an HTML element

id event(EventTarget|string node,string event,function handler, [object context] );
nodeEventTarget|stringthe HTML node or its id
eventstringthe name of an HTML event (without the 'on' prefix)
handlerfunctionthe event handler
contextobjectcontext object with additional settings (described below)
idevent handler ID (can be used by the eventRemove() method)

Example

// adds a handler for the 'onclick' event of some HTML element
webix.event("divId", "click", function(e){
    //e - a native event object
    do_something();
});
 
// adds a handler for the 'onKeyUp' event of the List component
webix.event($$("list").getNode(), "keyup", function(e){
    //e - a native event object
    do_something();
}, {bind:$$("list")});

Related samples

Details

The optional context parameter may include:

  • bind - (object) an object that the this keyword refers to;
  • capture - (boolean) a flag that indicates on which stage (capture or bubble) event should be captured. false by default;
  • id - (string) event handler ID (if not set, will be generated automatically).
See also
Back to top