Items API Methods
once()
Set up a one-time event listener for a specified event that will execute the callback function once and then stop listening to the event.
You would want to use this method so that you can execute some custom logic the first time an event is fired, such as displaying a message the first time the learner unfocuses the assessment, for example.
The full list of available event names are listed on the Items API Events page.
Examples
// Sets up a one-time listener for the 'focused' event.
itemsApp.once('focused', focusHandler);
Arguments
-
eventName string
Name of the event that you want to listen to.
-
eventCallback function
Callback function that will be triggered when the event is fired.
-
context object
Execution context that will be used for
this
when the callback function is triggered.
Return value
None (undefined
).
Related articles
- List of all Items API Events
- The
on()
method, the method used to add custom event listeners to the assessment events. - The
off()
method, the method used to remove custom event listeners from the assessment events. - Items API Events live demo