How to modify jQuery mobile history Back Button behavior

后端 未结 6 1417
忘了有多久
忘了有多久 2020-12-13 21:47

I\'ll start this off with I have researched a bit, but no solution that solves what seems like it should be a simple JQM modification.

I have a wine review webapp th

6条回答
  •  甜味超标
    2020-12-13 22:12

    If you have the situation that you want the close button refer to an arbitrary (not the last) page, you could also change first to the target page and open the dialog afterwards. Therefore the close button at the dialog will open the target page.

    // First: change to the target page
    $.mobile.changePage('#target_page');
    

    Afterwards open the dialog like this.

    // Second: change to the dialog 
    window.setTimeout(
       // for some reason you have to wrap it in a timeout  
       function(){
          $.mobile.changePage('#dialog');
       },
       1
    );
    

    Now you can open the dialog and the close button will open #target_page.

    Advantages:

    • solution works for single dialogs rather than removing all close buttons from all dialogs
    • seamless integration on a single point of code
    • history manipulation is not needed

提交回复
热议问题