]> git.mjollnir.org Git - moodle.git/commitdiff
Made it so you can call require_js after header printed (bug 8823)
authorsam_marshall <sam_marshall>
Fri, 9 Mar 2007 12:52:35 +0000 (12:52 +0000)
committersam_marshall <sam_marshall>
Fri, 9 Mar 2007 12:52:35 +0000 (12:52 +0000)
lib/ajax/ajaxlib.php

index a2bd8b8ef403aaec2e2fbb96362cde63d2c8414d..e1691269095c61413273b695df821d2f187cfe37 100644 (file)
@@ -35,6 +35,14 @@ function require_js($lib='') {
             $libpath = ajax_get_lib($lib);
             if (array_search($libpath, $loadlibs) === false) {
                 $loadlibs[] = $libpath;
+                // If this is called after header, then we print it right away
+                // as otherwise nothing will ever happen!
+                if (defined('HEADER_PRINTED')) {
+                    $realloadlibs=$loadlibs;            
+                    $loadlibs=array($libpath);
+                    print require_js();
+                    $loadlibs=$realloadlibs;
+                }
             }
         }
     } else {