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.

Pop

With cobalt.navigate.pop(options), the current view is closed and Cobalt comes back to the latest page in the current navigation. On iOS, there is a slide back transition and on Android, the activity is closed.

options is an optionnal object parameter that may contains the folowing keys:

  • data (optionnal) data to send back to the previous page. The previous page will receive this data in the cobalt:onPageShown message.

  • page (optionnal) is the html page on which you want to go back. Cobalt will go backward and stop on the first matching couple of page and controller it found.

  • controller (optionnal) is the name of the view on which you want to go back. This view should be defined in the cobalt.json file. Default to any Cobalt controller.

Examples

//pop the previous page
cobalt.navigate.pop();

//pop the previous page with some data
// previous page will receive {foo: 'bar'} in onPageShown data.
cobalt.navigate.pop({ data: { foo: 'bar'}}); 

//pop to the previous index page with controller myController
cobalt.navigate.popTo({ page : "index.html", controller:"myController" });
Clone this wiki locally