Search code examples
androiddojoibm-mobilefirstdojox.mobileworklight-runtime

IBM Worklight 6.0 - How to override the Back button?


I have developed a Worklight application Using Dojo 1.9. In my application for returning to previous view i am using a back button in my app's header.

Back Button Code

<div data-dojo-type="dojox.mobile.Heading"
                data-dojo-props="label:'View2 Details',back:'View1', moveTo:'view1'" style="background-color: maroon">
                </div>

Is it possible to use the device's back button to navigate to previous view? so that I can use both approaches in my app?


Solution

  • Two alternate solutions:

    1. The simplest would be to rely on Dojo Mobile's "bookmarkable" feature. For details, see https://dojotoolkit.org/reference-guide/dojox/mobile/bookmarkable.html. Live example: http://download.dojotoolkit.org/release-1.9.0/dojo-release-1.9.0/dojox/mobile/tests/test_bk_force-list.html. After transitioning from the home page, pressing browser's back button on desktop browsers, or the back button of Android devices, triggers a transition back to the initial view.

    2. The saner solution for a relatively complex app requiring navigation history management would be to build your app using dojox/app. See the documentation at http://dojotoolkit.org/reference-guide/1.9/dojox/app.html and the tutorials at https://dojotoolkit.org/documentation/tutorials/1.9/dojox_app/.