Event Author API

navigate

Fires when the app location changes, for example, when visiting an Item from the Item list, when doing a search, or when going back from an Item to the Item list.

You would want to be notified about this event firing, because you might want to take some action when the author navigates to another page, for example.

When the event has been fired, you can use event.preventDefault() to prevent the navigation to the new page.

Examples

// Standard usage to listen to the event
authorApp.on('navigate', function (event) {
    console.log('This code executes when the Author API app has navigated to a new page.');
});

// Prevent navigating to a new page
authorApp.on('navigate', function (event) {
    if (shouldNotNavigate) {
        event.preventDefault();
    }
});

Callback arguments

The event callback function will be called with an AuthorEvent instance as an argument (unless indicated otherwise). The AuthorEvent object provides further information for the event that has been fired. Additional data attributes listed below can be accessed from the event.data object. The AuthorEvent object will look like the example below:

authorApp.on('[name of the fired event]', function (event) {
    console.log(event);
    /*
        {
            "name": "[name of the fired event]",
            "data": {
                // additional data attributes
            }
        }
    */
});
  • location string
    The current page location, for example, activities/search.
  • locationEncoded string
    The URI encoded version of current location.
  • route string
    The current matching route for the app, for example, activities/search/:query

Related articles

Was this article helpful?