[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/event-delegate/ -> event-delegate.js (summary)

Adds event delegation support to the library.

File Size: 354 lines (13 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 function

  delegate()

Functions
Functions that are not part of a class:

delegate(type, fn, el, filter)   X-Ref
<p>Sets up event delegation on a container element.  The delegated event
will use a supplied selector or filtering function to test if the event
references at least one node that should trigger the subscription
callback.</p>

<p>Selector string filters will trigger the callback if the event originated
from a node that matches it or is contained in a node that matches it.
Function filters are called for each Node up the parent axis to the
subscribing container node, and receive at each level the Node and the event
object.  The function should return true (or a truthy value) if that Node
should trigger the subscription callback.  Note, it is possible for filters
to match multiple Nodes for a single event.  In this case, the delegate
callback will be executed for each matching Node.</p>

<p>For each matching Node, the callback will be executed with its 'this'
object set to the Node matched by the filter (unless a specific context was
provided during subscription), and the provided event's
<code>currentTarget</code> will also be set to the matching Node.  The
containing Node from which the subscription was originally made can be
referenced as <code>e.container</code>.

param: type {String} the event type to delegate
param: fn {Function} the callback function to execute.  This function
param: el {String|node} the element that is the delegation container
param: filter {string|Function} a selector that must match the target of the
param: context optional argument that specifies what 'this' refers to.
param: args* 0..n additional arguments to pass on to the callback function.
return: {EventHandle} the detach handle



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1