While the widget runs, it triggers some events that the hosting page can listen to using the postmessage plugin. Each event also includes data relevant to the event. The ObjectinstanceId from the started event is stored so it can be used later in other APIs.
Use the following method to register an event:

MethodReturn ValueDescriptionExample
registerEvent(eventName:
string, callback
([event params]));
None Registers an event with the callback that is invoked when the event is triggered. webselfservice.registerEvent
('started', function(e)
{
intid.value=e.objectInstanceId;
instanceid = e.objectInstanceId;
});

The most common events used in conjunction with the registerEvent API are:

  • started: Fires when a new Interaction is started.
  • loaded: Fires just after a new page is loaded into the content area.
  • ended: Fired when an Interaction is finished.

For a full list of events and arguments, refer to Web Self Service Widget Events.
The following example shows how to listen for a loaded event. When a particular page is loaded, an alert message is sent.

<script>
var instanceId;
pm.bind("loaded", function(e) {
console.log("epage.pagenavigation.navigationTitle");
});
pm.bind("started", function(e) {
instanceId = e.objectInstanceId;
console.log("started");
});
pm.bind("interactionEnded", function() {
console.log("ended");
});
</script>

Revision:

Comments