Skip to content
Wai Ho Leung edited this page May 8, 2014 · 10 revisions

WikiAPI ReferenceEvent

Utilities for handling event delegation, normalization between touch and mouse/trackpad events, custom events, and tying events to blocks.


# Event.off(elem, eventname, handler)

Removes an event handler.

  • elem: The elements that will have the event removed.
  • eventname: A string representing the event type being removed.
  • handler: The handler to be removed.

===

# Event.on(elem, eventname, selector, handler[, onceOnly])

Attaches an event handler function for one or more events to the selected elements.

  • elem: An element or a selector string that will have the event attached.
  • eventname: A string representing the event type to listen for.
  • selector: A selector that the handler executes on.
  • handler: A function to execute when the event is triggered.
  • onceOnly: true if the event is only handled once; false otherwise.

===

# Event.once(elem, eventname, selector, handler)

Registers an event handler on the event target and removes it immediately after the event is fired.

  • elem: An element or a selector that will have the event attached.
  • eventname: A string representing the event type to listen for once.
  • selector: A selector that the handler executes on
  • handler: A function to execute when the event is triggered.

===

# Event.trigger(elemOrSelector, eventname, data)

Executes all handlers and behaviors attached to the matched elements for the given event type.

  • elemOrSelector: An element or a selector that will have the event triggered.
  • eventname: A string representing the event type to be triggered.
  • data: An object providing custom information about the event.
Clone this wiki locally