open.activity - Events - Author API

Author API Events

open:activity

Fires when an Activity in the Activity list is clicked.

You would want to be notified about this event firing, because you might want to take some action when the author selects an Activity, for example.

When the event has fired, you can use event.preventDefault() to prevent the Activity from being opened.

Examples

// Standard usage to listen to the event
authorApp.on('open:activity', function (event) {
    console.log('This code executes when an Activity has been clicked.');
});

// Prevent navigating to a new page
authorApp.on('open:activity', function (event) {
    if (shouldNotOpenActivity) {
        event.preventDefault();
    }
});

Callback arguments

  • activityJson object

    JSON of the Activity being opened. By default, this object may not include the full Activity JSON; for example, data.items may be empty and some fields may be omitted.

    Important To retrieve the complete Activity JSON, enable the activity_list.full_activity_json initialization option.

Was this article helpful?

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