How to trigger a data-rel=“back” button in JQuery

2020-03-28 04:29发布

I am using "page widget" to implement a dialog in jquery mobile with data-dialog="true", everything is fine, i can also back to the previous page with the back button. I have implemented some actions on the dialog and need to close the dialog page after the actions are done.

I have tried with $("#page").dialog("close"); and $.mobile.pageContainer.pagecontainer("change","#previousPageId"); both haven't worked for me. How can i trigger the back button on page dialog with javascript?

I am using jQuery mobile 1.4.3 and jQuery 1.11.1. Thanks for your answer and any comments are welcome.

2条回答
Melony?
2楼-- · 2020-03-28 05:08

This should work:

$(':mobile-pagecontainer').pagecontainer('change', <pageid>, { reverse: false });

Reverse-option being true/false determines whet ever you are going backwards or forwards. True means back I think.

查看更多
家丑人穷心不美
3楼-- · 2020-03-28 05:35

Dialog widget is deprecated as of 1.4, hence, .dialog("close") is no longer a valid function.

To go back to previous page:

  • jQuery Mobile

    $.mobile.back();
    
  • JavaScript

    window.history(-1)
    
查看更多
登录 后发表回答