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)
|
||||||
*/
|
*/
|
||||||
|
if (typeof url === "function") {
|
||||||
console.warn('You are using a deprecated H5P library. Please upgrade!');
|
console.warn('You are using a deprecated H5P library. Please upgrade!');
|
||||||
let args = Array.prototype.slice.call(arguments);
|
let args = Array.prototype.slice.call(arguments);
|
||||||
args.unshift('load');
|
args.unshift('load');
|
||||||
return H5P.jQuery.fn.on.apply(this, args);
|
return H5P.jQuery.fn.on.apply(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return H5P.jQuery.fn.__originalLoad.apply(this, arguments);
|
||||||
|
}
|
Loading…
Reference in New Issue