Reputation: 1295
I am following this tutorial:
http://jaydata.org/tutorials/creating-a-stand-alone-web-application
So after including this:
<script src="jquery-1.12.4.min.js"></script>
<script src="jaydata-1.5.5-rc/jaydata.js"></script>
I am trying to run this sample code (I copied and pasted that):
$data.Entity.extend("$org.types.Department", {
Id: { type: "int", key: true, computed: true },
Name: { type: "string", required: true },
Address: { type: "string" },
Employees: { type: "Array", elementType: "$org.types.Employee", inverseProperty: "Department" }
});
alert($data.Entity.Department);
$data.Entity.extend("$org.types.Employee", {
Id: { type: "int", key: true, computed: true },
FirstName: { type: "string", required: true },
LastName: { type: "string", required: true },
Department: { type: "$org.types.Department", inverseProperty: "Employees" }
});
$data.EntityContext.extend("$org.types.OrgContext", {
Department: { type: $data.EntitySet, elementType: $org.types.Department },
Employee: { type: $data.EntitySet, elementType: $org.types.Employee }
});
But in the Browser I get the error message, that "$org.types.Department" is not defined. This is driving me crazy, because I am doing exactly what the easy tutorial says.
Any suggestions?
Upvotes: 0
Views: 97
Reputation: 1646
JayData 1.5.x stopped using global variables, so when you define a new type, put it in a variable and reference that in the elementType.
var departmentType = $data.Entity.extend("$org.types.Department", ...
var employeeType = $data.Entity.extend("$org.types.Employee", ...
$data.EntityContext.extend("$org.types.OrgContext", {
Department: { type: $data.EntitySet, elementType: departmentType },
Employee: { type: $data.EntitySet, elementType: employeeType }
});
Upvotes: 0