解决了我之前的问题(ember-data error while loading route: 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>