thiswayup
thiswayup

Reputation: 2077

AMD loading widgets using Dojo 1.7

I've created a widget which I want to load via AMD in dojo 1.7. I want to be able to place my custom widgets libs on the same level as the dojo folder.

It appears that it always uses the base path of dojo and so need to put widgets inside the dojo folder, however libs that come with dojo doesnt need to follow that rule eg dijit and dojox.

I've tried changing the base path and a

<script>
    dojoConfig = {
        isDebug: true,
        parseOnLoad: true,
        async:true
        //,baseUrl: '../src/js'
    };
</script>

<script type="text/javascript" src="js/dojo/dojo.js"></script>

<script type="text/javascript">
    console.log('start1');
    require(
        ["dojo/ready"
         ,"dijit/Tree"
         ,"screeningResults/ScreeningResults"
        ],
        function(ready,tree, screening){
            var screeningUI = new screening({}, "screeningUI");
            screeningUI.startup();
        }
    );
</script>

Upvotes: 2

Views: 748

Answers (2)

Philippe
Philippe

Reputation: 6828

Supposing your directory structure is like this :

  • dojo/dijit
  • dojo/dojox
  • dojo/dojo
  • src/js/mymodule

You should do :

<script>
    dojoConfig = {
        isDebug: true,
        parseOnLoad: true,
        async:true
        packages : [{name : 'mymodule', location : '/src/js/mymodule'}]
    };
</script>

Upvotes: 2

thiswayup
thiswayup

Reputation: 2077

Turns out you need to use the "aliases" parameter and pass in an array of the aliases inside another array. example in http://jsfiddle.net/tr_grc/ZVaRZ/

Upvotes: 0

Related Questions