The object type that handles events for modules and behaviors. Exposed publicly to allow developers to use in their own code. To create a new instance, specify the DOM element to handle events for and an object containing event handlers (onclick
, onmousedown
, etc., the same as for modules and behaviors):
var delegate = new Box.DOMEventDelegate(element, {
onclick: function(event) {
console.log(event.type);
}
});
You may also pass a custom list of events to handle as a third parameter (v2.4.0+):
var delegate = new Box.DOMEventDelegate(element, {
ontouchstart: function(event) {
console.log(event.type);
}
}, ['touchstart']);
var eventTypes = [
'click', 'mouseover', 'mouseout', 'mousedown',
'mouseup', 'mouseenter', 'mouseleave', 'mousemove',
'keydown', 'keyup', 'submit', 'change', 'contextmenu',
'dblclick', 'input', 'focusin', 'focusout'
];
Attaches all events for the delegate.
var delegate = new Box.DOMEventDelegate(element, {
onclick: function(event) {
console.log(event.type);
}
});
delegate.attachEvents();
Detaches all events for the delegate.
var delegate = new Box.DOMEventDelegate(element, {
onclick: function(event) {
console.log(event.type);
}
});
delegate.detachEvents();