Dojo 1.4 - 1.5 Migration problem dojo.dnd.Source

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rythmic
    New Member
    • Feb 2010
    • 29

    Dojo 1.4 - 1.5 Migration problem dojo.dnd.Source

    Hi!

    I was successfully using dojo.dnd.Source with Dojo 1.4.3 loaded from my webserver. However, as it is shared hosting or for some other reason the loading was horrifyingly slow. (even something like 1min30 secs occasionally)

    So I am now trying to switch to DOJO 1.5 and googleapis as source. Result is much better loading times but my problem now is that dojo.dnd is not recognized. here is the code I use for loading dojo.dnd.Source

    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript" djConfig="parseOnLoad: true, isDebug: true"></script>
    <script language="JavaScript">
                 
                 dojo.addOnLoad(function() {                
                    dojo.require("dijit.Dialog");
                    dojo.require("dojo.parser");
                    dojo.require("dijit.Editor");
                    dojo.require("dojo.dnd.Source");
                    
                    widgetSrcNode = new dojo.dnd.Source("admin_widgetSrcNode", {accept:["unknown"]});
    The error message I'm getting is as follows:
    dojo.dnd is undefined
    http://mydomain.com/admin/somepage.php?wp =17
    Line 171

    -- end of message

    Line 171: widgetSrcNode = new dojo.dnd.Source ("admin_widgetS rcNode", {accept:["unknown"]});

    I can't see any changes in the documentation for dojo.dnd in 1.5 vs 1.4 and I have tried several djconfig options but no luck. What else can I try?
  • rythmic
    New Member
    • Feb 2010
    • 29

    #2
    I will answer this question myself.

    Here is the problem. I did not only switch versions. I also changed the source of DOJO to a CDN.

    Calling dojo.js from my own server makes the whole library of dojo available at the next line. This is not the case with calling dojo.js from a CDN. The CDN delivers the different components of dojo asynchronously meaning we don't know that the required functionality will be readily available at the next line.

    So what is the solution?
    Code:
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" type="text/javascript"></script>
    <script language="JavaScript">
                 // put the requires outside of dojo.addonload
                 dojo.require("dojo.dnd.Source");
                 dojo.require("dijit.Dialog");
                 dojo.require("dojo.parser");
                 dojo.require("dijit.Editor");
                 
                 dojo.addOnLoad(function() {                
                  // do whatever needs to be done here now that the required files are loaded for sure  
                    widgetSrcNode = new dojo.dnd.Source("admin_widgetSrcNode", {accept:["unknown"]});
    An easy change of the order of the code was enough to fix the problem.

    Comment

    Working...