navigate - Events - Author Aide API

Author Aide API Events

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
authorAideApp.on('navigate', function (event) {
    console.log('This code executes when the Author Aide API app has navigated to a new page.');
});

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

Callback arguments

  • location string

    The URL being navigated to.

  • locationEncoded string

    The URI encoded version of the URL.

  • route string

    The route pattern. See routes for more information.

  • from string

    The previous URL.

  • to string

    The URL being navigated to (same as location).

  • preventDefault() function

    Function to prevent the navigation.

  • defaultPrevented boolean

    Boolean indicating if navigation was prevented.

Related articles

  • The navigate() method, which allows you to navigate to a specific page in the Author Aide API.
Was this article helpful?

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