Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Dojo on RequireJS

Tags:

requirejs

dojo

I am using Dojo 1.9.1 and RequireJS

I implemented it using this code:

 <script src="require.js"></script>
 <script type="text/javascript">
      requirejs.config({
        baseUrl: location.pathname.replace(/\/[^/]+$/, '') + '/js/',  // magic!
        packages: [
          {
            name: 'dojo',
            location: "http://ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/"
          }
        ]
     }); 
 </script>

... ..

<script>
      require(["dojo/domReady!"], function() { 
       ......
      });
    </script>

it will throw some exceptions about has.js not work correctly

Uncaught TypeError: Object function (){} has no method 'add' has.js:8
Uncaught Error: Load timeout for modules: dojo/domReady!_unnormalized2

Does any one have an explanation, or an idea about how to solve it?

like image 363
Slim Tekaya Avatar asked May 24 '26 15:05

Slim Tekaya


1 Answers

The CDN version of Dojo is built assuming that you are using the Dojo loader in order to decrease code size. Part of the code removal is the alternative has.js implementation that is used if a loader doesn’t include one (like RequireJS). You can use a regular downloaded version of Dojo with RequireJS and it will work fine, but you can’t use the CDN version.

like image 150
C Snover Avatar answered May 27 '26 05:05

C Snover



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!