2

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>
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • 1
    I believe your script's `src` attribute should be `src="dojodatagrid/dojo.js".` – Default Mar 28 '13 at 23:05
  • Do you include `claro.css`? Sometimes I forget that and the grid does not render. – Jess Mar 29 '13 at 01:56
  • @Jessemon i forgot to include it but it didn't solved the problem ;) i followed the tutorial and there was nothing said from any css. For the path : i tried both and they both work :) but the errors stay – Matthias De Schoenmacker Mar 29 '13 at 10:19
  • 2
    Try using a CDN for a test, ``. – Jess Mar 29 '13 at 12:11
  • @MatthiasDeSchoenmacker, I'm glad! I changed my comment into a proper answer. Please accept it. By the way, there is some debate as to whether a CDN should be used in a production site or not. http://stackoverflow.com/questions/1447184/microsoft-cdn-for-jquery-or-google-cdn – Jess Apr 01 '13 at 12:47

2 Answers2

2

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>

Jess
  • 23,901
  • 21
  • 124
  • 145
0

You probably installed dgrid using CPM inside dojodatagrid. Your src must be src="dojodatagrid/dojo/dojo.js" and not src="dojodatagrid/dojo.js"

madmed
  • 606
  • 6
  • 13
  • The first exception indicates that dojo.js _is_ being loaded, so the src must point to the right place – Attila Nov 01 '13 at 14:09