From 79fe00fcb5143e5dce0bf06f1f49e5dc241e0979 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 19 Jul 2019 22:00:53 +0200 Subject: slx-fixes.js: Make .cachedScript more compatible to .getScript Allow passing a success callback directly --- script/slx-fixes.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/script/slx-fixes.js b/script/slx-fixes.js index be35f56b..e8380702 100644 --- a/script/slx-fixes.js +++ b/script/slx-fixes.js @@ -108,11 +108,17 @@ $(document).ready(function() { }); // Caching script fetcher (https://api.jquery.com/jQuery.getScript/); use exactly like $.getScript -jQuery.cachedScript = function(url, options) { +jQuery.cachedScript = function(url, callback, options) { + if (!$.isFunction(callback)) { + options = callback; + callback = undefined; + } options = $.extend( options || {}, { + type: "get", dataType: "script", cache: true, - url: url + url: url, + success: callback }); return jQuery.ajax( options ); }; -- cgit v1.2.3-55-g7522