event

webix.event(node, event, handler, context)

webix.event helper.

Please look into the linked official documentation.

References

helpers
_events(), assert(), bind(), toNode(), uid().

External references

Official documentation page.

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
webix.event=function(node,event,handler,context){
    context = context || {};
    node = webix.toNode(node);
    webix.assert(node, "Invalid node as target for webix.event");

    var id = context.id || webix.uid();
    if(context.bind)
        handler=webix.bind(handler,context.bind);

    if (!context.inner)
        webix._events[id]=[node,event,handler,context.capture];    //store event info, for detaching

    //use IE's of FF's way of event's attaching
    if (node.addEventListener)
        node.addEventListener(event, handler, !!context.capture);
    else if (node.attachEvent)
        node.attachEvent("on"+event, webix._events[id][2] = function(){
            return handler.apply(node, arguments);    //IE8 fix
        });

    return id;    //return id of newly created event, can be used in eventRemove
};

//remove previously attached event