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

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

Modal

With cobalt.navigate.modal(options) a new navigation is started from this point. You can choose a page and a controller, and push some other pages in it.

The new page appears from the bottom of the app to the top.

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 (optionnal) 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.

Dismiss

When cobalt.navigate.dismiss() is called in a page that has been opened with a cobalt.navigate.modal(options), the user will be driven back to the page that opened the modal at first time.

dismiss takes an optionnal parameter :

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

Examples

//open next.html in MyCustomControllerName controller.
cobalt.navigate.modal({ page : "next.html", controller:"myController" });

//dismiss the current modal and navigation stack.
cobalt.navigate.dismiss();

Notice

This uses the real "modal" component on iOS but fakes it on Android.

We will rework the feature as soon we will be able to custom animations on push transistion and we will use the popTo command under the hood.

We believe we will keep those modal and dismiss commands at least as a shortcut.

Clone this wiki locally