Load Dojo from CDN using jQuery

Load Dojo from CDN using jQuery

Here is the Dojo example that perfectly works 

   
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" media="screen">
  5. <script type="text/javascript">
  6. dojoConfig = {
  7. parseOnLoad: false,
  8. async: true
  9. };
  10. </script>
  11. <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js" type="text/javascript"></script>
  12. <script type="text/javascript">
  13. /// Require the registry, parser, Dialog, and wait for domReady
  14. require(["dijit/registry", "dojo/parser", "dojo/json", "dojo/_base/config", "dijit/Dialog"], function (registry, parser, JSON, config) {
  15. // Explicitly parse the page
  16. parser.parse();
  17. // Find the dialog
  18. var dialog = registry.byId("dialog");
  19. // Set the content equal to what dojo.config is
  20. dialog.set("content", "<b>it works!</b>");
  21. // Show the dialog
  22. dialog.show();
  23. });
  24. </script>
  25. </head>
  26. <body class="claro">
  27. <div id="dialog" data-dojo-type="dijit.Dialog"></div>
  28. </body>
  29. </html>

now I want to modify it and load Dojo dynamically using jQuery. Here is the example how I do this: 

    
  1. <!DOCTYPE HTML>
  2. <html lang="en">
  3. <head>
  4. <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" media="screen">
  5. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
  6. <script type="text/javascript">
  7. $(document).ready(function () {
  8. dojoConfig = {
  9. parseOnLoad: false,
  10. async: true
  11. };

  12. $.getScript("http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js")
  13. .done(function (script, textStatus) {
  14. /// Require the registry, parser, Dialog, and wait for domReady
  15. require(["dijit/registry", "dojo/parser", "dojo/json", "dojo/_base/config", "dijit/Dialog"], function (registry, parser, JSON, config) {
  16. // Explicitly parse the page
  17. parser.parse();
  18. // Find the dialog
  19. var dialog = registry.byId("dialog");
  20. // Set the content equal to what dojo.config is
  21. dialog.set("content", "<b>it works!</b>");
  22. // Show the dialog
  23. dialog.show();
  24. });
  25. })
  26. .fail(function (jqxhr, settings, exception) {
  27. alert('Cannot load Dojo.js');
  28. });
  29. });
  30. </script>
  31. </head>
  32. <body class="claro">
  33. <div id="dialog" data-dojo-type="dijit.Dialog">
  34. </div>
  35. </body>
  36. </html>


but looks like I do something wrong cause it raises the next error: 

  1. NotFoundError: Node was not found
  2. http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js
  3. Line 2

I suspect that Dojo is not ready yet but maybe I'm wrong... Is it possible to use jQuery to load Dojo dynamically at all?