Use jQuery.getScript to dynamically load script
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
5b61ef9213
commit
365f68372f
|
@ -368,15 +368,9 @@ var OCP = {},
|
||||||
addScript:function(app,script,ready){
|
addScript:function(app,script,ready){
|
||||||
var deferred, path=OC.filePath(app,'js',script+'.js');
|
var deferred, path=OC.filePath(app,'js',script+'.js');
|
||||||
if(!OC.addScript.loaded[path]) {
|
if(!OC.addScript.loaded[path]) {
|
||||||
deferred = jQuery.ajax({
|
deferred = $.Deferred();
|
||||||
url: path,
|
$.getScript(path, function() {
|
||||||
cache: true,
|
deferred.resolve();
|
||||||
success: function (content) {
|
|
||||||
window.eval(content);
|
|
||||||
if(ready) {
|
|
||||||
ready();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
OC.addScript.loaded[path] = deferred;
|
OC.addScript.loaded[path] = deferred;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue