common.trigger

Executes all event listeners added with on() method.
trigger(eventData)
eventData object, parameters of the event
Returns object.

Description

Internally, all w2ui widgets call trigger to execute event listeners. You can add your own events and trigger them with the trigger function. The trigger function should be called twice. First time before the default behavior is processed and the second time after it it processed. This is needed to accomplish the functionality provided by the event flow.
Here is an example how widgets trigger events: As you see from the example above, the default action can be cancelled by event handler calling event.preventDefault(). There is no need to return event object because JavaScript passes objects by reference and changing the event within the handler will change the original object.
You can also define event.onComplete as a call back when the default actions of the event are completed if you need to do some actions after event has been processed.

User Comments

comments powered by Disqus