once - Methods - Items API

Items API Methods


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.


// Sets up a one-time listener for the 'focused' event.
itemsApp.once('focused', focusHandler);


  • 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

Was this article helpful?

Did you arrive here by accident? If so, learn more about Learnosity.