Tank2005
Tank2005

Reputation: 909

How to close with the back button when a dialog is active on jQuery mobile

I am creating an Android App UI with PhoneGap and jQuery moble. Although the dialog of jQuery mobile was displayed on HTML, when the back key of the device is pressed, this application will be exited. I would like to close not an application but its dialog. What should I program?

Upvotes: 1

Views: 957

Answers (1)

keune
keune

Reputation: 5795

You should listen to backbutton event and act accordingly. Something like this should work:

document.addEventListener("backbutton", function() {
  $('your_dialog_element').dialog('close');
}, false);

Upvotes: 2

Related Questions