Change fallback to original jquery .load() if first arg is not a function
parent
c472d5172d
commit
555442d37e
|
@ -5,18 +5,18 @@ H5P.jQuery = jQuery.noConflict(true);
|
||||||
H5P.jQuery.fn.__originalLoad = H5P.jQuery.load;
|
H5P.jQuery.fn.__originalLoad = H5P.jQuery.load;
|
||||||
|
|
||||||
H5P.jQuery.fn.load = function (url, params, callback) {
|
H5P.jQuery.fn.load = function (url, params, callback) {
|
||||||
if (typeof url === "string") {
|
|
||||||
return H5P.jQuery.fn.__originalLoad.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE:
|
* NOTE:
|
||||||
* This is needed in order to support old libraries that uses the .load() function
|
* This is needed in order to support old libraries that uses the .load() function
|
||||||
* for elements in the deprecated jQuery way (elem.load(fn)), the correct way to do this
|
* for elements in the deprecated jQuery way (elem.load(fn)), the correct way to do this
|
||||||
* now is elem.on('load', fn)
|
* now is elem.on('load', fn)
|
||||||
*/
|
*/
|
||||||
console.warn('You are using a deprecated H5P library. Please upgrade!');
|
if (typeof url === "function") {
|
||||||
let args = Array.prototype.slice.call(arguments);
|
console.warn('You are using a deprecated H5P library. Please upgrade!');
|
||||||
args.unshift('load');
|
let args = Array.prototype.slice.call(arguments);
|
||||||
return H5P.jQuery.fn.on.apply(this, args);
|
args.unshift('load');
|
||||||
|
return H5P.jQuery.fn.on.apply(this, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return H5P.jQuery.fn.__originalLoad.apply(this, arguments);
|
||||||
}
|
}
|
Loading…
Reference in New Issue