Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The "Node was not found" error is caused by the loader trying to locate the script tag that loaded it. This is a <em>trick</em> that Dojo uses when it is loaded from a CDN (like the Google one you have used) to try to find the url path for loading modules.</p> <p>The jQuery $.getScript() function is not actually injecting a script tag into the page but rather loading via XHR and then evaling the code. Hence, the tag that Dojo is looking for cannot be found. This only happens when using a CDN. If you used your own local copy of Dojo rather than a CDN, it can be made to work.</p> <p>I'm not sure that loading Dojo via jQuery is good practice. It is probably better to load both of them separately or to do it the other way round (ie. load jQuery inside of Dojo). I assume that you require the functionality of both or you wouldn't be trying this.</p> <p>To load jQuery as Dojo module you could alter your code as follows:</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" media="screen" /&gt; &lt;script type="text/javascript"&gt; var dojoConfig = { "parseOnLoad": false, "async": true, "packages": [{ "name": "jquery", "location": "//ajax.googleapis.com/ajax/libs/jquery/1.9.0", "main": "jquery.min" }] }; &lt;/script&gt; &lt;script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js" &gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; define.amd.jQuery = true; // jQuery will be loaded as an AMD module require([ "jquery", ], function($){ // NB: $ is only available within the scope it has been loaded // as it is loading as an AMD module. Hence, $ is not globally // available and must be required into any scope it is used. $(document).ready(function () { require([ "dijit/registry", "dojo/parser", "dojo/json", "dojo/_base/config", "dijit/Dialog" ], function (registry, parser, JSON, config) { // Explicitly parse the page parser.parse(); // Find the dialog var dialog = registry.byId("dialog"); // Set the content equal to what dojo.config is dialog.set("content", "&lt;b&gt;it works!&lt;/b&gt;"); // Show the dialog dialog.show(); }); }); }) &lt;/script&gt; &lt;/head&gt; &lt;body class="claro"&gt; &lt;div id="dialog" data-dojo-type="dijit/Dialog"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>It is probably better to stick to using Dojo, rather than trying to use both. However, the above will allow both to be used together. Dojo, has it's own ready function (<a href="http://dojotoolkit.org/reference-guide/1.8/dojo/ready.html" rel="nofollow">dojo/ready</a>) that could replace $(document).ready(). Most of the functionality of jQuery is replicated in some manor within Dojo.</p> <p>Loading jQuery as a Dojo module means that it is only available inside the require callback. Hence, $ is not placed in the global scope as is normally the case. You will have to require it into any JavaScript you need it for.</p> <p><strong>NB:</strong> I changed dijit.Dialog in your code to dijit/Dialog as it will not load in version 1.8 if you use the dot formation.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload