Question

I tried to use JayData based on the following tutorial. I created my JS file with JaySVCUtil and the context is the following:

$data.EntityContext.extend('MyCtx.MyContext', {
    'DataTable1': { type: $data.EntitySet, elementType:MyCtx.DataTable1}
});

I have the following scripts included:

<script src="Scripts/datajs-1.0.3.js"></script>
<script src="Scripts/jquery-1.8.0.js"></script>
<script src="Scripts/jaydata.js"></script>
<script src="Scripts/jaydata-vsdoc.js"></script>
<script src="Scripts/jaydataproviders/oDataProvider.js"></script>
<script src="Scripts/MyCtx.js"></script>

I try to use it in my webpage:

function db () {
    alert("test1");
    var mongo = new MyCtx.MyContext({ name: 'oData', oDataServiceHost: 'http://xxxxxx.azurewebsites.net/MongoDataService.svc' });
    alert("test2");
}

The first alert is shown then I get the following error:

ReferenceError: MyCtx is not defined

If I modify to

new MyContext(...)

then the error is the following:

ReferenceError: MyContext is not defined

What should I do?

Was it helpful?

Solution

It seems that the JS files are loaded asynchronously so the JS file containing the context class has not been loaded yet when it was referenced (loading should consider references, though).

After a few swaps of the loaded <script> lines, it has been resolved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top