Yingding Wang
Yingding Wang

Reputation: 500

How to trigger a data-rel="back" button in JQuery Mobile 1.4.3 with javascript?

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.

Upvotes: 2

Views: 3247

Answers (2)

Omar
Omar

Reputation: 31732

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)
    

Upvotes: 2

Swiffy
Swiffy

Reputation: 4693

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.

Upvotes: 0

Related Questions