Skip to content

Commit

Permalink
Data Ajax: Prevents the caching of nested scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentGoderre committed Nov 27, 2014
1 parent 3ac7496 commit a3db871
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/plugins/data-ajax/data-ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $document.on( "timerpoke.wb " + initEvent + " " + updateEvent + " ajax-fetched.w
"prepend"
],
len = ajaxTypes.length,
$elm, ajaxType, i, content;
$elm, ajaxType, i, content, jQueryCaching;

for ( i = 0; i !== len; i += 1 ) {
ajaxType = ajaxTypes[ i ];
Expand Down Expand Up @@ -117,12 +117,19 @@ $document.on( "timerpoke.wb " + initEvent + " " + updateEvent + " ajax-fetched.w
content = event.fetch.response;
if ( content ) {

//Prevents the force caching of nested resources
jQueryCaching = jQuery.ajaxSettings.cache;
jQuery.ajaxSettings.cache = true;

// "replace" is the only event that doesn't map to a jQuery function
if ( ajaxType === "replace") {
$elm.html( content );
} else {
$elm[ ajaxType ]( content );
}

//Resets the initial jQuery caching setting
jQuery.ajaxSettings.cache = jQueryCaching;
}
}
}
Expand Down

0 comments on commit a3db871

Please sign in to comment.