Search code examples
javascriptdojoundefineddgrid

Dojo, dgrid define is not defined


I am new to dojo and dgrid. I was following the tutorial on the site but I have two errors

Uncaught ReferenceError: define is not defined dojo.js:1

Uncaught ReferenceError: require is not defined index.html:10

I copied the code from http://dojofoundation.org/packages/dgrid/tutorials/hello_dgrid/ and changed the folder name as it was said.

The files are in the right place and I can't find the problem. Maybe I need to change something in the dojo files.

<script src="dojodatagrid\dojo.js" data-dojo-config="async: true"></script>
<script>
    require(["dgrid/Grid", "dojo/domReady!"], 
    function(Grid){
        var data = [
            { first: "Bob", last: "Barker", age: 89 },
            { first: "Vanna", last: "White", age: 55 },
            { first: "Pat", last: "Sajak", age: 65 }
        ];

        var grid = new Grid({
            columns: {
                first: "First Name",
                last: "Last Name",
                age: "Age"
            }
        }, "grid");
        grid.renderArray(data);
    });
</script>

Solution

  • As a test, try using a CDN like this:

    <script data-dojo-config="async: 1" src="//ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js"></script>