余烬数据断言失败:无法对未定义的对象使用“查询”调用 get
ember-data Assertion failed: Cannot call get with 'query' on an undefined object
解决我之前的问题(加载路由时出现余烬数据错误:TypeError {}) 出现了一个新错误,因为我认为这个问题与上一个问题无关,我决定为它创建一个新问题。
我现在得到的错误是:
XHR finished loading: "http://www.shoutzor.nl//api/emberstore/tracks/85/".
Assertion failed: Cannot call get with 'query' on an undefined object. ember.js:394
Uncaught TypeError: Cannot read property '__ember1382024509870_meta' of undefined
(注意:"www.shoutzor.nl"后面的双斜杠不会产生问题,JSON 响应仍然正确)
编辑:似乎问题源于这些代码片段之一,因为当我从网站中删除所有与搜索相关的代码时,它再次正常工作(我也应该注意,当我访问像"/#/search/something"这样的网址时,它确实有效)。
Shoutzor = Ember.Application.create();
Shoutzor.Router.map(function() {
//Home Page
this.route("home", { path: "/" });
//Track Page
this.route("track", { path: "/track/:id" });
//Search page
this.route("search", { path: "/search" });
this.route("search", { path: "/search/:query" });
});
Shoutzor.SearchRoute = Ember.Route.extend({
setupController: function(controller) {
controller.set('pageTitle', "Search");
},
renderTemplate: function() {
this.render('SearchPageContent', { outlet: 'pageContent', into: 'application' });
}
});
Shoutzor.ApplicationController = Ember.Controller.extend({
// the initial value of the `search` property
search: '',
actions: {
query: function() {
//the current value of the text field
var query = this.get('search');
this.transitionToRoute('search', { query: query });
}
}
});
Shoutzor.SearchController = Ember.Controller.extend();
和我的 HTML:
<script type="text/x-handlebars" data-template-name="SearchPageContent">
{literal}
<h1>Searching for: "{{search}}"</h1>
{{input type="text" value="search" action="query"}}
{/literal}
</script>
似乎是地图导致了这个问题,
改变
this.route("search", { path: "/search" });
this.route("search", { path: "/search/:query" });
到
this.resource("search", { path: "/search" }, function() {
this.route(':query');
});
解决了我的问题
相关文章:
- 在mongoose中使用正则表达式在对象数组中进行查询搜索
- MongoDB嵌套对象数组后查询
- jQuery对象从html表中查询为两个一维数组,用于Chartist图表
- 如何将查找对象值传递到FetchXml查询中
- 使用查询将对象数组发布到asp.net-mvc控制器操作的正确方法是什么
- javascript对象与阅读文档——初学者查询效率
- 如何在dojo中查询对象类型
- 如何在 GET 请求中序列化查询的对象
- j查询设置中的数据表对象
- j查询对象到字符串请帮助
- 解析查询查找方法返回对象而不是数组
- j查询选择器不选择对象
- angularjs $resource将查询资源列表转换为对象数组
- j查询对象预期错误
- 如何在javascript中克隆mongoose查询对象
- 当查询返回对象时,Express Mongo回调返回undefined
- 将查询字符串反序列化为JSON对象
- Javascript对象查询
- 为一个angularjs对象查询dom
- 猫鼬:对嵌套对象查询不正确的ObjectId时报错