Question

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?

Was it helpful?

Solution 2

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/.

OTHER TIPS

I am not familiar with the concept of "pages" in Dojo, however:

Yes, there is WL.App.overrideBackButton, that you can use to override the default Android Back button functionality (quitting the app) and instead call a callback that will load a different view.

Note that in order to restore the "quit" functionality when the app is in the index page, you will need to use WL.App.resetBackButton so that the user will be able to quit the app like how s/he is used to in Android.

As for how to handle a multi-page navigation with history, please see the relevant topic in this training module. You will have to adjust the code to that you use in Dojo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top