我正在学习本教程:
http://jaydata.org/tutorials/creating-a-stand-alone-web-application
所以包括这个:
<script src="jquery-1.12.4.min.js"></script>
<script src="jaydata-1.5.5-rc/jaydata.js"></script>
我正在尝试运行此示例代码(我复制并粘贴了该代码):
$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 }
});
但是在浏览器中我收到错误消息,&#34; $ org.types.Department&#34;没有定义。 这让我很生气,因为我正在做的简单教程就是这样。
有什么建议吗?
答案 0 :(得分:0)
JayData 1.5.x停止使用全局变量,因此在定义新类型时,将其放在变量中并引用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 }
});