DOMEventDelegate

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']);

Default Event Types Handled

var eventTypes = [
    'click', 'mouseover', 'mouseout', 'mousedown',
    'mouseup', 'mouseenter', 'mouseleave', 'mousemove',
    'keydown', 'keyup', 'submit', 'change', 'contextmenu',
    'dblclick', 'input', 'focusin', 'focusout'
];

attachEvents

Description

Attaches all events for the delegate.

Example

var delegate = new Box.DOMEventDelegate(element, {
    onclick: function(event) {
        console.log(event.type);
    }
});

delegate.attachEvents();

detachEvents

Description

Detaches all events for the delegate.

Example

var delegate = new Box.DOMEventDelegate(element, {
    onclick: function(event) {
        console.log(event.type);
    }
});

delegate.detachEvents();