mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-11 01:41:01 +00:00
Make sure that Ajax form submissions (both get and post) always make a new request, even if it's identical to a previous submission. When a duplicate cached result page is present, it'll be removed from the DOM after the page change is complete . Thanks @medovob for the ideas and feature request. Fixes #368, Fixes #366
This commit is contained in:
parent
b13ddf345c
commit
ea12c75940
1 changed files with 15 additions and 2 deletions
|
|
@ -233,13 +233,16 @@
|
|||
url = fileUrl = $.type(to) === "string" ? to.replace( /^#/, "" ) : null,
|
||||
data = undefined,
|
||||
type = 'get',
|
||||
isFormRequest = false,
|
||||
duplicateCachedPage = null,
|
||||
back = (back !== undefined) ? back : ( urlStack.length > 1 && urlStack[ urlStack.length - 2 ].url === url ),
|
||||
transition = (transition !== undefined) ? transition : ( pageTransition || "slide" );
|
||||
|
||||
if( $.type(to) === "object" ){
|
||||
url = to.url,
|
||||
data = to.data,
|
||||
type = to.type;
|
||||
type = to.type,
|
||||
isFormRequest = true;
|
||||
//make get requests bookmarkable
|
||||
if( data && type == 'get' ){
|
||||
url += "?" + data;
|
||||
|
|
@ -286,6 +289,11 @@
|
|||
}, 500);
|
||||
}
|
||||
removeActiveLinkClass();
|
||||
|
||||
//if there's a duplicateCachedPage, remove it from the DOM now that it's hidden
|
||||
if( duplicateCachedPage != null ){
|
||||
duplicateCachedPage.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if(transition){
|
||||
|
|
@ -336,13 +344,18 @@
|
|||
}
|
||||
|
||||
// find the "to" page, either locally existing in the dom or by creating it through ajax
|
||||
if ( to.length ) {
|
||||
if ( to.length && !isFormRequest ) {
|
||||
if( fileUrl ){
|
||||
setBaseURL(fileUrl);
|
||||
}
|
||||
enhancePage();
|
||||
transitionPages();
|
||||
} else {
|
||||
|
||||
//if to exists in DOM, save a reference to it in duplicateCachedPage for removal after page change
|
||||
if( to.length ){
|
||||
duplicateCachedPage = to;
|
||||
}
|
||||
|
||||
pageLoading();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue