Fix script loading race condition
authorColeman Watts <coleman@civicrm.org>
Thu, 6 Apr 2017 18:12:13 +0000 (14:12 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 6 Apr 2017 18:12:13 +0000 (14:12 -0400)
js/Common.js

index fae46f6495fcaadedc1c642f459c49aeac8b8f7c..691df6c15e222b651ce25c73fe6e1aa073c3e41e 100644 (file)
@@ -243,10 +243,13 @@ if (!CRM.vars) CRM.vars = {};
       var script = document.createElement('script');
       scriptsLoaded[url] = $.Deferred();
       script.onload = function () {
-        if (window.jQuery === CRM.$ && CRM.CMSjQuery) {
-          window.jQuery = CRM.CMSjQuery;
-        }
-        scriptsLoaded[url].resolve();
+        // Give the script time to execute
+        window.setTimeout(function () {
+          if (window.jQuery === CRM.$ && CRM.CMSjQuery) {
+            window.jQuery = CRM.CMSjQuery;
+          }
+          scriptsLoaded[url].resolve();
+        }, 100);
       };
       // Make jQuery global available while script is loading
       if (window.jQuery !== CRM.$) {