Skip to content
Extraits de code Groupes Projets
Valider fbc09569 rédigé par cerdic's avatar cerdic
Parcourir les fichiers

Fix #3562 : jQuery.load appelle jQuery.ajax, et dans ce cas ce dernier ne doit...

Fix #3562 : jQuery.load appelle jQuery.ajax, et dans ce cas ce dernier ne doit pas appeler triggerAjaxLoad
Pour corriger ca on passe un triggerAjaxLoad:false en data, qui est ensuite vide par jQuery.ajax
parent dbb450b4
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -49,6 +49,7 @@ if(!jQuery.spip.load_handlers) { ...@@ -49,6 +49,7 @@ if(!jQuery.spip.load_handlers) {
params = null; params = null;
} }
} }
params = jQuery.extend(params, {triggerAjaxLoad:false}); // prevent $.ajax to triggerAjaxLoad
var callback2 = function() {jQuery.spip.log('jQuery.load');jQuery.spip.triggerAjaxLoad(this);callback.apply(this,arguments);}; var callback2 = function() {jQuery.spip.log('jQuery.load');jQuery.spip.triggerAjaxLoad(this);callback.apply(this,arguments);};
return jQuery.spip.intercepted.load.apply(this,[url, params, callback2]); return jQuery.spip.intercepted.load.apply(this,[url, params, callback2]);
}; };
...@@ -86,13 +87,13 @@ if(!jQuery.spip.load_handlers) { ...@@ -86,13 +87,13 @@ if(!jQuery.spip.load_handlers) {
if (typeof url == 'string') { if (typeof url == 'string') {
settings['url'] = url; settings['url'] = url;
} }
// if triggerAjaxLoad is prevented, finish without faking callback
if (settings.data && settings.data['triggerAjaxLoad'] === false) {
settings.data['triggerAjaxLoad'] = null;
return jQuery.spip.intercepted.ajax(settings);
}
var s = jQuery.extend(true, {}, jQuery.ajaxSettings, settings); var s = jQuery.extend(true, {}, jQuery.ajaxSettings, settings);
var callbackContext = s.context || s; var callbackContext = s.context || s;
try {
if (jQuery.ajax.caller==jQuery.spip.intercepted.load || jQuery.ajax.caller==jQuery.spip.intercepted.ajaxSubmit)
return jQuery.spip.intercepted.ajax(settings);
}
catch (err){}
var orig_complete = s.complete || function() {}; var orig_complete = s.complete || function() {};
settings.complete = function(res,status) { settings.complete = function(res,status) {
// Do not fire OnAjaxLoad if the dataType is not html // Do not fire OnAjaxLoad if the dataType is not html
...@@ -101,7 +102,7 @@ if(!jQuery.spip.load_handlers) { ...@@ -101,7 +102,7 @@ if(!jQuery.spip.load_handlers) {
? res.getResponseHeader("content-type"): ''; ? res.getResponseHeader("content-type"): '';
var xml = !dataType && ct && ct.indexOf("xml") >= 0; var xml = !dataType && ct && ct.indexOf("xml") >= 0;
orig_complete.call( callbackContext, res, status); orig_complete.call( callbackContext, res, status);
if(!dataType && !xml || dataType == "html") { if((!dataType && !xml) || dataType == "html") {
jQuery.spip.log('jQuery.ajax'); jQuery.spip.log('jQuery.ajax');
if (typeof s.onAjaxLoad=="undefined" || s.onAjaxLoad!=false) if (typeof s.onAjaxLoad=="undefined" || s.onAjaxLoad!=false)
jQuery.spip.triggerAjaxLoad(s.ajaxTarget?s.ajaxTarget:document); jQuery.spip.triggerAjaxLoad(s.ajaxTarget?s.ajaxTarget:document);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter