Minh Pham
Minh Pham

Reputation: 974

How to import dojo javascript file into worklight application?

When creating a new project, I have selected to include the dojo toolkit. I can import dojo.js using src="dojo/dojo.js". However when I try importing some other modules such as dijit.js using

require(["dijit/dijit"], function(){})

...I always get an error in the web console (ie the resource is not found). The problem is not applied when I import dojo modules. How can I fix this?

Upvotes: 1

Views: 915

Answers (2)

Mohammad Arif
Mohammad Arif

Reputation: 7581

Make sure, you have configured Dojo correctly, kindly find the Dojo configuration which I have been using in my Hybrid App.

<script>
    var dojoConfig = {
    baseUrl: "js",
    packages: [
        { name: "dojo", location: "dojo/dojo"},
        { name: "dijit", location: "dojo/dijit"},
        { name: "dojox", location: "dojo/dojox"}
    ],
        isDebug: false,
        async: true,
        parseOnLoad: true,
        deps:['app/main']
    }
</script>

If you still not able to resolve it, try to make a sample use case or jsfiddle, would look into it further.

Upvotes: 1

Mithlesh Kumar
Mithlesh Kumar

Reputation: 758

You made simple mistake of syntax:- To require js file instead of require[("dojo/parser")] you have use require(["dojo/parser"],function(parser){})

Upvotes: 0

Related Questions