Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

properly handle popups in dialogs, make sure dialog closes on page ch…

…anges
  • Loading branch information...
commit 242cf05850f45f8bf23b7373f6635394d9664f36 1 parent 9226d96
John Bender johnbender authored
Showing with 15 additions and 10 deletions.
  1. +15 −10 js/widgets/popup.js
25 js/widgets/popup.js
View
@@ -585,39 +585,44 @@ define( [ "jquery",
open: function( options ) {
+ var hashkey = $.mobile.dialogHashKey,
+ activePage = $.mobile.activePage;
+
// make sure open is idempotent
if( $.mobile.popup.active ) {
return;
}
- var self = this, url = $.mobile.activePage.jqmData( "url" ), newUrl;
+ var self = this, url = activePage.jqmData( "url" );
// if the current url has no dialog hash key proceed as normal
// otherwise, if the page is a dialog simply tack on the hash key
- if ( url.indexOf( $.mobile.dialogHashKey ) == -1 ) {
- newUrl = url + $.mobile.dialogHashKey;
- } else if ( $.mobile.activePage.is( ".ui-dialog" ) ) {
- newUrl = $.mobile.path.parseLocation().hash + $.mobile.dialogHashKey;
+ if ( url.indexOf( hashkey ) == -1 && !activePage.is( ".ui-dialog" ) ){
+ url = url + hashkey;
+ } else {
+ url = $.mobile.path.parseLocation().hash + hashkey;
}
// make sure the popup is displayed
this._open( options );
- // Gotta love methods with 1mm args :(
- $.mobile.urlHistory.addNew( newUrl, undefined, undefined, undefined, "dialog" );
-
// swallow the the initial navigation event, and bind for the next
$.mobile.pageContainer.one( "navigate.popup", function( e ) {
e.preventDefault();
// any navigation event after a popup is opened should close the popup
- $.mobile.pageContainer.one( "navigate.popup", function() {
+ // NOTE the pagebeforechange is bound to catch navigation events that don't
+ // alter the url (eg, dialogs from popups)
+ $.mobile.pageContainer.one( "navigate.popup pagebeforechange.popup", function() {
self._close();
});
});
+ // Gotta love methods with 1mm args :(
+ $.mobile.urlHistory.addNew( url, undefined, undefined, undefined, "dialog" );
+
// set the new url with (or without) the new dialog hash key
- $.mobile.path.set( newUrl );
+ $.mobile.path.set( url );
},
close: function() {
Please sign in to comment.
Something went wrong with that request. Please try again.