EventDelegation Class
Event delegation - Attach an event handler to a container element to handle events for inner elements. This has several advantages, including improved performance when a lot of elements are involved (as less event handlers are attached), and not having to attach event handlers to AJAX-loaded content.
Methods
add
(
chainable
-
containerEl -
type -
tagName -
className -
fn
Attach a handler to all tagNames with a class of className, by attaching the event listener to containerEl. Works for both current elements, and new elements added in the future.
Parameters:
-
containerElElementContainer element to add event listener to
-
typeStringType of event listener (eg. "click")
-
tagNameStringTag name to add events to (eg. "a")
-
classNameStringClass name to add events to, or null for none
-
fnFunctionEvent handler function
handle
(
private
-
e
Handle a delegated event
Parameters:
-
eEventEvent data
Properties
delegates
Object
private
The current delegates
