Slim Tekaya
Slim Tekaya

Reputation: 347

Running Dojo on RequireJS

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?

Upvotes: 3

Views: 1210

Answers (1)

C Snover
C Snover

Reputation: 18766

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.

Upvotes: 4

Related Questions