Permalink
Browse files

[dialog] Prevent the click-handler for "Close" acting twice - Fixes: #…

  • Loading branch information...
1 parent 33b28ae commit fbcc0e415f123d30de80f1db2ef71e07dbc6b174 @gabrielschulhof gabrielschulhof committed Apr 18, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 js/jquery.mobile.dialog.js
@@ -18,6 +18,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
var self = this,
$el = this.element,
headerCloseButton = $( "<a href='#' data-" + $.mobile.ns + "icon='delete' data-" + $.mobile.ns + "iconpos='notext'>"+ this.options.closeBtnText + "</a>" ),
+ closeButtonNotYetClicked = true,
dialogWrap = $("<div/>", {
"role" : "dialog",
"class" : "ui-dialog-contain ui-corner-all ui-overlay-shadow"
@@ -46,7 +47,10 @@ $.widget( "mobile.dialog", $.mobile.widget, {
// Use click rather than vclick in order to prevent the possibility of unintentionally
// reopening the dialog if the dialog opening item was directly under the close button.
headerCloseButton.bind( "click", function() {
- self.close();
+ if ( closeButtonNotYetClicked ) {
+ closeButtonNotYetClicked = false;
+ self.close();
+ }
});
/* bind events
@@ -68,6 +72,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
})
.bind( "pagehide", function( e, ui ) {
$( this ).find( "." + $.mobile.activeBtnClass ).removeClass( $.mobile.activeBtnClass );
+ closeButtonNotYetClicked = true;
})
// Override the theme set by the page plugin on pageshow
.bind( "pagebeforeshow", function(){

1 comment on commit fbcc0e4

Owner

gnarf commented on fbcc0e4 Apr 26, 2012

Further comments from IRC:

gnarf: also, looking at the actual code, it seems to me now that dialog( "close" ) x 2 would still have the same problem?
gnarf: or however you programmatically call it
gnarf: self.close() should probably be aware of its "closing" status rather than the click handler
Please sign in to comment.