- <!DOCTYPE HTML>
- <html lang="en">
- <head>
- <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" media="screen">
- <script type="text/javascript">
- dojoConfig = {
- parseOnLoad: false,
- async: true
- };
- </script>
- <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js" type="text/javascript"></script>
- <script type="text/javascript">
- /// Require the registry, parser, Dialog, and wait for domReady
- 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", "<b>it works!</b>");
- // Show the dialog
- dialog.show();
- });
- </script>
- </head>
- <body class="claro">
- <div id="dialog" data-dojo-type="dijit.Dialog"></div>
- </body>
- </html>
now I want to modify it and load Dojo dynamically using jQuery. Here is the example how I do this:
- <!DOCTYPE HTML>
- <html lang="en">
- <head>
- <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dijit/themes/claro/claro.css" media="screen">
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- dojoConfig = {
- parseOnLoad: false,
- async: true
- };
- $.getScript("http://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js")
- .done(function (script, textStatus) {
- /// Require the registry, parser, Dialog, and wait for domReady
- 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", "<b>it works!</b>");
- // Show the dialog
- dialog.show();
- });
- })
- .fail(function (jqxhr, settings, exception) {
- alert('Cannot load Dojo.js');
- });
- });
- </script>
- </head>
- <body class="claro">
- <div id="dialog" data-dojo-type="dijit.Dialog">
- </div>
- </body>
- </html>
but looks like I do something wrong cause it raises the next error:
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?