首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Easy Jaydata示例失败

Easy Jaydata示例失败
EN

Stack Overflow用户
提问于 2016-07-26 22:07:42
回答 1查看 78关注 0票数 0

我正在学习本教程:

http://jaydata.org/tutorials/creating-a-stand-alone-web-application

因此,在包含以下内容之后:

代码语言:javascript
复制
<script src="jquery-1.12.4.min.js"></script>
<script src="jaydata-1.5.5-rc/jaydata.js"></script>

我正在尝试运行这个示例代码(我复制并粘贴了它):

代码语言:javascript
复制
$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 }
});

但在浏览器中,我收到错误消息,即"$org.types.Department“未定义。这让我抓狂,因为我完全按照简单的教程所说的去做。

有什么建议吗?

EN

回答 1

Stack Overflow用户

发布于 2016-11-03 17:43:33

JayData 1.5.x不再使用全局变量,因此当您定义新类型时,请将其放入变量并在elementType中引用该变量。

代码语言:javascript
复制
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 }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38592160

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档