Javascript Event System dispatchEvent() Example
From KickApps Documentation
The dispatchEvent() method is generally used internally, but you may define your own events if you would like to.
Contents |
Basic event dispatching
Ka.events.dispatchEvent("this-is-a-custom-event");
Event dispatching with additional data
This example shows how to pass custom data from the event to the event handler.
Ka.events.dispatchEvent("this-is-a-custom-event", {customData: "this is a custom event!"});
Dispatch event and return value of event handler
This example will allow you to return the value that is returned from the event handler.
return Ka.events.dispatchEvent("this-is-a-custom-event", {customData: "this is a custom event!"});
Dispatch event and halt execution if event handler returns false
If the event handler returns false, the execution will halt and will not continue to the next line. In this case, alert("Event fired!") will not happen if the event handler returns false. Any other return value will cause the execution to continue normal.
alert("Firing event...");
if (!Ka.events.dispatchEvent("this-is-a-custom-event", {customData: "this is a custom event!"})) return false;
alert("Event fired!");
Favorites









