Skip to content

Commit fbcc0e4

Browse files
author
Gabriel Schulhof
committed
[dialog] Prevent the click-handler for "Close" acting twice - Fixes: jquery-archive#3387
1 parent 33b28ae commit fbcc0e4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

js/jquery.mobile.dialog.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
1818
var self = this,
1919
$el = this.element,
2020
headerCloseButton = $( "<a href='#' data-" + $.mobile.ns + "icon='delete' data-" + $.mobile.ns + "iconpos='notext'>"+ this.options.closeBtnText + "</a>" ),
21+
closeButtonNotYetClicked = true,
2122
dialogWrap = $("<div/>", {
2223
"role" : "dialog",
2324
"class" : "ui-dialog-contain ui-corner-all ui-overlay-shadow"
@@ -46,7 +47,10 @@ $.widget( "mobile.dialog", $.mobile.widget, {
4647
// Use click rather than vclick in order to prevent the possibility of unintentionally
4748
// reopening the dialog if the dialog opening item was directly under the close button.
4849
headerCloseButton.bind( "click", function() {
49-
self.close();
50+
if ( closeButtonNotYetClicked ) {
51+
closeButtonNotYetClicked = false;
52+
self.close();
53+
}
5054
});
5155

5256
/* bind events
@@ -68,6 +72,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
6872
})
6973
.bind( "pagehide", function( e, ui ) {
7074
$( this ).find( "." + $.mobile.activeBtnClass ).removeClass( $.mobile.activeBtnClass );
75+
closeButtonNotYetClicked = true;
7176
})
7277
// Override the theme set by the page plugin on pageshow
7378
.bind( "pagebeforeshow", function(){

0 commit comments

Comments
 (0)