Upgrading a project to dojo 1.7.2 from 1.6.0. While I could simply point to the new version (it seems quite backward compatible), I think it’s time to switch to the new AMD compatible require / declare syntax.
Step 1. Pointed at the CDN and set async to true:
<script type="text/<span class=">// <![CDATA[ // <![<span class="hiddenSpellError" pre="">CDATA</span>[ // ]]></script> javascript" src="//ajax.googleapis.com/ajax/libs/dojo/1.7.2/dojo/dojo.js" // ]]></script> data-dojo-config="async: true, parseOnLoad:true"> </script>
Immediately the async: true caused dojo is undefined errors from dojo.byId and dojo.require statements.
// A slide out tab dojo.require("dojo.fx"); dojo.addOnLoad(function() { dojo.animateProperty({ node:"slideOutBox", properties: { height: 0 } }).play(); });
The fix was pretty easy
Step 2. Change dojo.require to require and move dojo.addOnLoad into
require([“dojo”,”dojo/fx”, “dojo/domReady!”], function(fx){
});
Upgrading custom dojo build to 1.7.2
First build overwrote dojo.js, oops, which gave this unhelpful error,
js: uncaught JavaScript runtime exception: ReferenceError: "require" is not defined.
Note: I should have finished this post a year ago when I was doing the upgrade. There were a few more issues I ran into but it’s a bit fuzzy now.
I was suggested this blog by my cousin. I am not sure whether this
post is written by him as no one else know such detailed about my difficulty.
You are wonderful! Thanks!