0

I used multi-page template (JQM) and created a single html file with 2 pages (Page0 and Page1). When the html file is loaded Page0 is shown. In page0, there is a link to page1. In page1, I have included a custom select menu, which opens a dialog box when it is clicked. So far so good. Here is the problem:

When page0 is loaded, I click page1 link and then click the select menu and choose an item from it. At this point, I expect to return page1 but for some weird reason I am directed to page0.

Investigated the issue and came across the following discussion and very similar example.

Here is a very long discussion on github, I am experiencing the same problem.

https://github.com/jquery/jquery-mobile/issues/4595

Please visit the following link to see the issue in action:

http://output.jsbin.com/iqogin/21

  1. click "Redirect to Page-1
  2. click "Open Dialog"
  3. click "close" button, and it goes back to Page-0 instead of Page-1

I use:

  • Jquery mobile 1.4.5
  • Jquery 1.11.1

Any suggestions?

Omar
  • 32,302
  • 9
  • 69
  • 112
Detroit
  • 17
  • 1
  • 4
  • It's because you navigate with `changeHash` set to true. When popup is closed, it triggers back navigation, this way you back to previous page in history. – Omar Mar 08 '16 at 13:19
  • @omar : please check example's [html code](http://output.jsbin.com/iqogin/21), changeHash attribute is explicitly assigned as "false" (if this is what you meant). However the issue is still there... – Detroit Mar 09 '16 at 03:12
  • http://plnkr.co/edit/AJ4rXrfuoy4x2b67UB7j?p=preview – Omar Mar 09 '16 at 09:00
  • 1
    Dear @omar, since you are the expert on the subject I am probably missing the obvious and can not see what you point out. I looked into your example and proceeded as described below: 1- clicked redirect to page 1 button 2- clicked go-to page 0 button 3- clicked redirect to page 1 again 4-clicked open dialog button 5- closed the dialog window and redirected back to page-0.. This is not what I want, I want to be redirected to page 1 where I opened the dialog box. I would appreciate if you could explain the obvious again... – Detroit Mar 09 '16 at 13:51
  • Okay, now I got what you mean. The issue is that you're using `changeHash: false`. If you remove it or set it to `true`, the problem will vanish. Or you will have to handle it yourself, using `pagecontainerbeforechange` when the dialog closes and move to previous page. Edit: like this with some tuning http://stackoverflow.com/a/26999356/1771795 – Omar Mar 09 '16 at 14:01
  • 1
    Dear @omar, your comment guided me to the right direction. I have added $.mobile.changePage.defaults.changeHash = false; into mobileinit but it did not seem to work for selectmenu dialog. However implementing [your solution](http://jsfiddle.net/Palestinian/ww2j7bpb/) fixed the problem with a small tweak : data.prevPage[0].id == "selectmenuId-dialog". I will start liking if I have enough reputation. Thanks!! – Detroit Mar 10 '16 at 03:23

0 Answers0