Class Event.Publisher
Event.Publisher
Description:
add support (to any object or class) by mixing this class into your own
Requires prototype.js
Usage:
To publish custom events:
1. mix this class with your own via
Object.extend( [your class or prototype], Event.Publisher )
2. post events by calling
this.dispatchEvent( [event name], [data for event] )
To activate and deactivate the event-tracing feature, just call
this.toggleEventsTrace()
Defined in: event.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
new Event.Publisher()
|
| Method Attributes | Method Name and Description |
|---|---|
|
addEventListener(event_name, callback_func, capturing)
Adds the observer function callback_func for the event event_name
(optionally capturing) to the current event publisher.
|
|
|
dispatchEvent(event_name, data, can_bubble, cancelable)
Post events by calling: this.dispatchEvent( [event name], [data for event] )
|
|
|
getEventTarget(event_name)
Private.
|
|
|
removeEventListener(event_name, callback_func, capturing)
Removes the observer function callback_func (where capturing must match)
from the event publisher.
|
|
Method Detail
addEventListener(event_name, callback_func, capturing)
Adds the observer function callback_func for the event event_name
(optionally capturing) to the current event publisher.
Called by Event.Listeners.
- Parameters:
- {String} event_name
- {Function} callback_func
- {Boolean} capturing
dispatchEvent(event_name, data, can_bubble, cancelable)
Post events by calling: this.dispatchEvent( [event name], [data for event] )
- Parameters:
- {String} event_name
- {Object} data
- {Boolean} can_bubble
- {Boolean} cancelable
getEventSourceId()
getEventTarget(event_name)
Private. Finds the secret element that this publisher will use to publish
the event event_name through the DOM.
- Parameters:
- {Object} event_name
isEventsTraceActive()
removeEventListener(event_name, callback_func, capturing)
Removes the observer function callback_func (where capturing must match)
from the event publisher.
- Parameters:
- {String} event_name
- {Function} callback_func
- {Boolean} capturing
toggleEventsTrace()