get multiple Scripts and then Callback

get multiple Scripts and then Callback

Hey there,

I'm currently working on something to enable me to beta test some functions without changing the html file and still leave everything running normal for the user. To do this I'm doing the following. I'm stroring a beta-variable in the localStorage and when it is set to true i want to load the scripts from another location. That works perfectly well but since i want to do this with some more scripts now, i want to load all scripts first, then do a callback. So far it looks like this

Script run directly from the html-Document
  1. function documentCustomReady(){
  2. var commonsPath;
  3. if(localStorage.getItem('testBeta')==='true'){
  4. commonsPath = 'somePath/_BETA/commons/';
  5. }else{
  6. commonsPath = 'somePath/commons/';
  7. }
  8. $.getMultipleScripts([
  9. specificPath + 'lopGgi.js',
  10. ],{
  11. Callback: function(){lopGgi.initCreateForm();}
  12. });

  13. }
And this is how I try to extend jQuery to enable it to get multiple Scripts

  1. $.extend({

  2. getMultipleScripts: function(Scripts, Settings){
  3. $.when(
  4. $(Scripts).each(function(){
  5. $.getScript(this.toString());
  6. }),
  7. $.Deferred(function(deferred){
  8. $(deferred.resolve);
  9. })
  10. ).done(function(){
  11. Settings.Callback();
  12. });
  13. }

  14. });

Sadly that doesn't work, as i always geht the error, that my functions I defined in the scripts to be loaded are not defined. The scripts get loaded though, it just seams the Callback is not able to access them. The whole when/done function still is a pretty big mistery to me but maybe you could help me out

Thanks in advance and