diff --git a/js/jquery.mobile.forms.select.custom.js b/js/jquery.mobile.forms.select.custom.js index 9640c94260e..3ec6882bf13 100644 --- a/js/jquery.mobile.forms.select.custom.js +++ b/js/jquery.mobile.forms.select.custom.js @@ -248,9 +248,11 @@ // rebind the page remove that was unbound in the open function // to allow for the parent page removal from actions other than the use // of a dialog sized custom select - self.thisPage.bind( "pagehide.remove", function() { - $(this).remove(); - }); + if( !self.thisPage.data("page").options.domCache ){ + self.thisPage.bind( "pagehide.remove", function() { + $(this).remove(); + }); + } // doesn't solve the possible issue with calling change page // where the objects don't define data urls which prevents dialog key diff --git a/tests/unit/select/cached-dom-cache-true.html b/tests/unit/select/cached-dom-cache-true.html new file mode 100755 index 00000000000..b5e719d36fa --- /dev/null +++ b/tests/unit/select/cached-dom-cache-true.html @@ -0,0 +1,65 @@ + + + + + + +
+
+ + +
+
+ + diff --git a/tests/unit/select/select_cached.js b/tests/unit/select/select_cached.js index dbc9f2192b0..1dfc54dd7fe 100644 --- a/tests/unit/select/select_cached.js +++ b/tests/unit/select/select_cached.js @@ -67,4 +67,35 @@ start ]); }); + + asyncTest( "dialog sized select shouldn't rebind its parent page remove handler when closing, if the parent page domCache option is true", function(){ + expect( 3 ); + + $.testHelper.pageSequence([ + resetHash, + + function(){ + $.mobile.changePage( "cached-dom-cache-true.html" ); + }, + + function(){ + $.mobile.activePage.find( "#domcache-page-select" ).siblings( 'a' ).click(); + }, + + function(){ + ok( $.mobile.activePage.hasClass('ui-dialog'), "the dialog came up" ); + $.mobile.activePage.find( "li a" ).last().click(); + }, + + function(){ + ok( $.mobile.activePage.is( "#dialog-select-parent-domcache-test" ), "the dialog closed" ); + $.mobile.changePage( $( "#default" ) ); + }, + + function(){ + same( $("#dialog-select-parent-domcache-test").length, 1, "make sure the select parent page is still cached in the dom after changing page" ); + start(); + } + ]); + }); })(jQuery); \ No newline at end of file