Permalink
Browse files

Popup: pagecontainerbeforechange with reloadPage requires immediate flag

The popup must not prevent default when going back to a page with the same URL
from which it was opened if the reloadPage flag is set. Rather, it must close
immediately, handling the page change event as if the user were navigating to a
different page.

Fixes gh-6119
Closes gh-7929
  • Loading branch information...
gabrielschulhof committed Jan 22, 2015
1 parent 07696be commit b3e036dd1b8a5f08afe63e2ac39a719f568190d5
View
@@ -838,7 +838,9 @@ $.widget( "mobile.popup", {
parsedDst = $.mobile.path.parseUrl( parsedDst );
toUrl = parsedDst.pathname + parsedDst.search + parsedDst.hash;
if ( this._myUrl !== $.mobile.path.makeUrlAbsolute( toUrl ) ) {
if ( this._myUrl !== $.mobile.path.makeUrlAbsolute( toUrl ) ||
data.options.reloadPage ) {
// Going to a different page - close immediately
immediate = true;
} else {
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Mobile Popup Form Submission Test Suite</title>
<script src="../../../external/requirejs/require.js"></script>
<script src="../../../js/requirejs.config.js"></script>
<script src="../../../js/jquery.tag.inserter.js"></script>
<script src="../../jquery.setNameSpace.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<link rel="stylesheet" href="../../../css/themes/default/jquery.mobile.css"/>
<link rel="stylesheet" href="../../../external/qunit/qunit.css"/>
<link rel="stylesheet" href="../../jqm-tests.css"/>
<script src="../../../external/qunit/qunit.js"></script>
<script>
$.testHelper.asyncLoad([
[ "widgets/popup" ],
[ "init" ],
[ "form_submission_core.js" ]
]);
</script>
<script src="../../swarminject.js"></script>
</head>
<body>
<div id="qunit"></div>
<form data-nstest-role="page">
<input type="hidden" name="abc" value="def">
<div data-nstest-role="popup" id="popup">
<button type="submit">Submit from popup</button>
</div>
<a href="#popup" data-nstest-rel="popup" id="open-popup-link">Open Popup</a>
</form>
</body>
</html>
@@ -0,0 +1,32 @@
asyncTest( "Form submission from popup works", function() {
expect( 4 );
var eventNs = ".formSubmissionFromPopupWorks";
$.testHelper.detailedEventCascade([
function() {
$( "#open-popup-link" ).click();
},
{
popupafteropen: { src: $( "#popup" ), event: "popupafteropen" + eventNs + "1" }
},
function( result ) {
deepEqual( result.popupafteropen.timedOut, false, "Popup did open" );
$( "#popup button" ).click();
},
{
submit: { src: $( document ), event: "submit" + eventNs + "2" },
popupafterclose: { src: $( "#popup" ), event: "popupafterclose" + eventNs + "2" },
pagecontainerchange: {
src: $( ":mobile-pagecontainer" ),
event: "pagecontainerchange" + eventNs + "3"
}
},
function( result ) {
deepEqual( result.submit.timedOut, false, "Submit event was triggered" );
deepEqual( result.popupafterclose.timedOut, false, "Popup did close" );
deepEqual( result.pagecontainerchange.timedOut, false, "Page did change" );
start();
}
]);
});

0 comments on commit b3e036d

Please sign in to comment.