diff --git a/javascript/jquery-ondemand/jquery.ondemand.js b/javascript/jquery-ondemand/jquery.ondemand.js index 90f9b18c6..fab4bce2a 100644 --- a/javascript/jquery-ondemand/jquery.ondemand.js +++ b/javascript/jquery-ondemand/jquery.ondemand.js @@ -1,11 +1,17 @@ /** * On-demand JavaScript handler + * * Based on http://plugins.jquery.com/files/issues/jquery.ondemand.js_.txt * and heavily modified to integrate with SilverStripe and prototype.js. * Adds capabilities for custom X-Include-CSS and X-Include-JS HTTP headers * to request loading of externals alongside an ajax response. * - * IMPORTANT: This plugin monkeypatches the jQuery.ajax() method. + * Requires jQuery 1.5 ($.Deferred support) + * + * CAUTION: Relies on customization of the 'beforeSend' callback in jQuery.ajaxSetup() + * + * @author Ingo Schommer (ingo at silverstripe dot com) + * @author Sam Minnee (sam at silverstripe dot com) */ (function($){ @@ -74,12 +80,12 @@ /** * Process the X-Include-CSS and X-Include-JS headers provided by the Requirements class */ - processOnDemandHeaders: function(xml, status, _ondemandComplete) { - var self = this; + processOnDemandHeaders: function(xml, status, xhr) { + var self = this, processDfd = new $.Deferred(); // CSS - if(xml.getResponseHeader('X-Include-CSS')) { - var cssIncludes = xml.getResponseHeader('X-Include-CSS').split(','); + if(xhr.getResponseHeader('X-Include-CSS')) { + var cssIncludes = xhr.getResponseHeader('X-Include-CSS').split(','); for(var i=0;i