Skip to content
Guillaume Gendre edited this page Jun 7, 2019 · 6 revisions

This function is part of the navigate functions to switch between views in a Cobalt application.

Replace

cobalt.navigate.replace(options) will replace the current page with the page you want without changing the app history.

The whole Activity or controller is replaced, it means the current page won't be in the navigation stack and you will not be able to pop to it.

You can use this for examples for a multiple steps form, an ad, or a side-menu implementation.

options may contains the folowing :

  • page (required) is the html page you want to load from the root web folder. This parameter is required for the "push" and "modal" types.

  • controller is the name of the view you want to load. This view should be defined in the cobalt.json file. Default to a Cobalt controller.

  • data Optionnal data to send to the next page. The next page will receive this data in the cobalt:onPageShown message.

  • animated : Define if the page transition should be animated or not. Default to true.

  • clearHistory : use this boolean to clear the whole navigation hystory while replacing the current view. This sets the next page as the root page of your app. You may use this for a signIn or signOut experience. Default is false.

Examples

//replace the current page with next.html and a default controller
cobalt.navigate.replace({ page : "next.html" });

//replace the current page with next.html and a MyCustomControllerName controller with no animation.
cobalt.navigate.replace({ page : "next.html", controller:"myController", animated:false });

//load home.html and sets it as the new root page of your app
cobalt.navigate.replace({ page : "home.html", clearHistory : true });
Clone this wiki locally