You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Element event management component. Allows you to unbind listeners by event type , or unbind every listener from an element.
It can work as a single global instance for managing all application events, but it's preferable to use it within another object that attaches events to elements, such as a template/view.
varEvents=require('events');varevents=newEvents();vara=document.querySelector('a');varonclick=function(){e.preventDefault();console.log(e.target);};events.bind(a,'click',function(){e.preventDefault();console.log(e.target);});events.bind(a,'click',onclick);events.bind(a,'dblclick',function(){e.preventDefault();console.log(e.target);});events.bind(a,'dblclick',function(){e.preventDefault();console.log(e.target+"2");});events.unbind(a,'click',onclick);// removes only the onclick listenerevents.unbind(a,'dblclick');// remove all the `dblclick` listenersevents.unbind(a);// remove all event listeners
API
.bind(el, type, callback)
Bind to el's event type with callback,
returns the callback passed.
.unbind(el, type, callback)
Unbind events from el, optionally specified by type and callback,
returns an array of unbound callbacks