Velocity.trigger()

Overview

Triggers a custom event in the Velocity scripting engine from the WebView engine. The Velocity engine should set an event handler using the WLEvent.on method.

Added in 2.1.33

Only available in the WebView engine context. For more information, see Velocity Scripting APIs.

Format

Velocity.trigger(eventName, parameters);

Parameter Description Type Required
eventName The custom event to trigger. String Required
parameters Parameters for the event. It must be an object in JSON format. String Optional

Trigger example

Copy
/* Trigger a timeout event in the WebView context
 */

var eventParams = JSON.stringify({url: window.location.href});
Velocity.trigger("InactivityTimeout", eventParams);


Handler example

Copy
/* The custom event handler in Velocity
 */

WLEvent.on("InactivityTimeout", function (event) {
  Logger.debug("Timed-out on url: " + event.url);
});