open

Page

Opens the page located at the specified url and tags it with the provided name. Pages in mowbly app are identified by name. Open method checks if any page is available with the provided name and if it finds one, it brings that page to foreground; creates a new page otherwise.

$m.open("order_details",

"/sales_rep_pack/OrderDetails.htm",

{"orderId":11045, "item":"I5692", "qty":100}); // open order details page

Syntax

        $m.open(name, url[, data, options])

Parameters

name

string (required)

Unique name for the page in the app.

url

string (required)

Url of the page to open. Possible values are,

  1. Relative url - Url relative to the app folder. The url should start with the pack name of the page. Supports only .htm or .html files.
  2. Absolute url - Any external url or internal files other than .htm/.html.

options

object (optional)  

Optional parameters for the open method. The object can contain the following properties,

  1. showProgress - {Optional. Boolean}. Flag that says if a progress bar should be displayed when the child page loads. Default value is true. The default progress text displays as 'Loading <page_name>...' and cannot be modified. The progress bar is dismissed in the ready event in the page.

  1. retainPageInViewStack - {Optional. String/File}. Flag that says if the page needs to be added to the view stack. Default value is true. Pages are pushed to the view stack as they open and are popped out when they close, displaying the next page in the view stack. However, in cases where a set of pages need to be transient that help user to do a temporary task in the app, it may be required to take the user back to the main page directly after the task is done. Also, the pages that are not retained in view stack are destroyed on close instead of taken to background thereby releasing the memory for the app.

data

object/string/number/boolean (required)

The data to be passed to the page. This data will be available to the function registered in $m.onData() of the page.

Remarks

Apps generally involve multiple pages and hence a requirement of data exchange between pages arises. Following are the ways to share data between pages;

  1. Preferences

Data that has to be shared between pages can be stored into preferences. The pitfall in using preferences is that preferences get persisted and the developer should take responsibility of clearing the preferences data when done. Else, data sharing can pose a risk of unnecessary content eating up the device memory.

  1. Page data and result

The page methods below can be used to share data between pages,

  1. open - Helps to pass data to a child page.
  2. setResult - Helps to return data to the parent page.

The advantage of using these page methods is that they don’t persist the data and hence are suitable for any transient data.

However, the size of the data passed to the page should be lesser to avoid any degradation in user experience as huge data would consume time and memory to process.