Changeset 13682 for dojo/trunk

Show
Ignore:
Timestamp:
05/10/08 17:29:47 (2 months ago)
Author:
jburke
Message:

Fixes #6727. Support a djConfig.addOnLoad option. Also updated API docs for djConfig.

Location:
dojo/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • dojo/trunk/tests/_base/_loader/afterOnLoad.html

    r12492 r13682  
    1010 
    1111                <script type="text/javascript"> 
    12                         window.onload = function(){ 
     12                        function init(){ 
    1313                                //Create global djConfig object first. We cannot use the djConfig attribute 
    1414                                //on the script tag since it may not be visible in some browsers at the time 
     
    2020                                        parseOnLoad: true, 
    2121                                        afterOnLoad:true, 
     22                                        addOnLoad: function(){ 
     23                                                //This function is registered with 
     24                                                //dojo.addOnLoad as Dojo is defined after 
     25                                                //being added to the DOM. 
     26                                                console.log("djConfig.addOnLoad callback fired OK: dojo.parser.parse is a " 
     27                                                        + (typeof dojo.parser.parse)); 
     28                                        }, 
    2229                                        require: [ 
    2330                                                'dojo.parser', 
     
    3744                                console.debug("onChange for id = " + id + ", value: " + newValue); 
    3845                        } 
     46                         
     47                        //Register onload init function that will add Dojo to the page. 
     48                        if(window.addEventListener){ 
     49                                window.addEventListener("load", init, false); 
     50                        }else{ 
     51                                window.attachEvent("onload", init); 
     52                        } 
     53 
    3954                </script> 
    4055        </head> 
  • dojo/trunk/_base/_loader/bootstrap.js

    r13411 r13682  
    7070        //              modules may be configured via `djConfig.modulePaths`. 
    7171        modulePaths: {}, 
     72        // afterOnLoad: Boolean  
     73        //              Indicates Dojo was added to the page after the page load. In this case 
     74        //              Dojo will not wait for the page DOMContentLoad/load events and fire 
     75        //              its dojo.addOnLoad callbacks after making sure all outstanding 
     76        //              dojo.required modules have loaded. 
     77        afterOnLoad: false, 
     78        // addOnLoad: Function or Array 
     79        //              Adds a callback via dojo.addOnLoad. Useful when Dojo is added after 
     80        //              the page loads and djConfig.afterOnLoad is true. Supports the same 
     81        //              arguments as dojo.addOnLoad. When using a function reference, use 
     82        //              `djConfig.addOnLoad = function(){};`. For object with function name use 
     83        //              `djConfig.addOnLoad = [myObject, "functionName"];` and for object with 
     84        //              function reference use 
     85        //              `djConfig.addOnLoad = [myObject, function(){}];` 
     86        addOnLoad: null, 
    7287} 
    7388=====*/ 
  • dojo/trunk/_base/_loader/loader.js

    r13283 r13682  
    203203                        d._callLoaded(); 
    204204                } 
     205        } 
     206 
     207        //Support calling dojo.addOnLoad via djConfig.addOnLoad. Support all the 
     208        //call permutations of dojo.addOnLoad. Mainly useful when dojo is added 
     209        //to the page after the page has loaded. 
     210        var dca = d.config.addOnLoad; 
     211        if(dca){ 
     212                d.addOnLoad[(dca instanceof Array ? "apply" : "call")](d, dca); 
    205213        } 
    206214