当我更改模型的属性时,我收到以下错误.
Uncaught Error: <DS.StateManager:ember466> could not respond to event setProperty in state rootState.loading.
Run Code Online (Sandbox Code Playgroud)
这是代码.http://jsfiddle.net/arenoir/JejwD/ http://jsfiddle.net/arenoir/JejwD/show
根据文件:
http://emberjs.com/guides/ember-data-lifecycle/
如果未加载,Ember数据将自动查找持久层以获取记录,如何仅加载find或甚至findAll已加载的记录?
除了创建一个非持久的加载记录列表,并在那里寻找记录?
我刚刚下载了ember-1.0.0-pre.4.js和ember-data-latest.js,并在应用初始化时收到以下错误:
未捕获的TypeError:对象Ember.Application没有方法'registerInjection'
我怎样才能解决这个问题?
我有一个项目列表,我正在从FIXTURES数据存储加载:
App.ItemsController = Ember.ArrayController.extend({
content: function() {
return App.Item.find();
}.property('content')
});
App.Item = DS.Model.extend({
name: DS.attr('string')
});
App.Item.FIXTURES = [
{id: 1, name: 'Item 1'},
{id: 2, name: 'Item 2'},
{id: 3, name: 'Item 3'},
{id: 4, name: 'Item 4'},
{id: 5, name: 'Item 5'},
{id: 6, name: 'Item 6'},
{id: 7, name: 'Item 7'},
{id: 8, name: 'Item 8'},
{id: 9, name: 'Item 9'},
{id: 10, name: 'Item 10'}
];
Run Code Online (Sandbox Code Playgroud)
我有一个简单的模板
<script type="text/x-handlebars" data-template-name="items">
<ul>
{{#each item in content}} …Run Code Online (Sandbox Code Playgroud) 我正在使用Ember Data beta2,我设置了hasMany关系.
在创建子记录时,我是否必须在父对应的属性上使用pushObject?
在查看文档时,我得到的印象是我需要正确设置记录的父属性并保存它.
我是这样做的:
addPlugin: function() {
//get the value
var title = this.get('newPluginName');
if (!title.trim()) { return; }
var plugin = {
name: title,
category: this.get('model'),
url: ''
};
var plugin = this.store.createRecord('plugin', plugin);
plugin.save();
//clear the text field
this.set('newPluginName', '');
$("#new-plugin").blur();
}
Run Code Online (Sandbox Code Playgroud)
我在Chrome中的Ember检查器中看到了新创建的记录,它并不脏,但它不存在于父列表中,刷新后它就消失了.
我正在使用Ember和Ember-Data.
App.InviteRoute = Ember.Route.extend({
model: function(params) {
return this.store.find('user', { invitation_token: params.token });
}
});
Run Code Online (Sandbox Code Playgroud)
这会ping我的服务器并返回单个用户记录,但该this.store.find()方法返回DS.PromiseArray.
我只需要知道如何使用任意字段使用Ember-Data获取单个对象.
在我的模板中:
<h1>This is the invite template.</h1>
<p>{{id}}</p>
<p>{{email}}</p>
Run Code Online (Sandbox Code Playgroud) 感谢Alex Spellers关于服务器端验证的教程,我为RestAdapter 实现了DS.Errors。
但是,在我的应用程序的这一部分中,我想做一个简单的客户端检查,以查看表单是否完整。(为什么没有DS.Errors处理所有错误?)
process: function(upload) {
var form = upload.get('form');
if (!isComplete(form)) {
upload.get('errors').add('field', 'field isempty');
return;
}
// else "Processing..."
Run Code Online (Sandbox Code Playgroud)
这里的逻辑有些简化,但是errors.add()应该无效,并向模型添加错误。但是我收到以下错误:
Uncaught Error: Attempted to handle event `becameInvalid` on <@model:upload:54a1f298ef912a2ace760b0f> while in state root.loaded.saved.
Run Code Online (Sandbox Code Playgroud)
我已经阅读了有关状态管理器的信息,但是不确定在向模型中添加错误之前应该如何以及将状态转换为什么状态。
提前致谢!
Ember : 1.8.1
Ember Data : 1.0.0-beta.11
Handlebars : 1.3.0
jQuery : 1.11.2
Run Code Online (Sandbox Code Playgroud) 我正在使用soundCloud json为用户收藏的歌曲.
你可以在这里看到它

我可以访问我的收藏夹曲目,但我无法访问用户ID和用户名.
这里我使用的代码返回我最喜欢的属性,我已经评论了无法返回用户属性的代码.
我在控制台中收到此错误"Uncaught TypeError:item.user.forEach不是函数"
我究竟做错了什么?它是访问我的用户属性的正确方法吗?
model: function(params) {
var artist, favoriteListProxy, self;
self = this;
artist = params.artist;
this.controllerFor('application').set('artistName', artist);
favoriteListProxy = Ember.ArrayProxy.create({
content: []
});
return new Ember.RSVP.Promise(function(resolve, reject) {
return SC.get("/users/" + 'mannaio' + "/favorites", {limit: 40}, function(favorites) {
if (favorites.length) {
favorites.forEach(function(item, index, arr){
var favorite;
favorite = self.createFavoritelist(item, favoriteListProxy);
// return item.user.forEach(function(user, index, arr){
// return user = self.createUser(user, favorite);
// });
});
favorites = favoriteListProxy.get('content')
return resolve(favorites);
}
});
});
}, …Run Code Online (Sandbox Code Playgroud) 我试图使用Laravel作为RESTfull API服务器和Ember作为我的fontend框架构建一个相当简单的应用程序
我的后端服务器依然存在 http://api.example.com/1.0/
我的前端继续存在 http://www.example.com/
我刚开始这个项目,所以我只有几个小时的开发时间,所以可能会有一些配置问题,我在这里失踪,但无论如何.
我试图从我的服务器获取产品列表,并使用ember-data在我的ember应用程序中显示它们
我正在运行ember 2.0.2和ember-data 2.0.0
我在chrome中遇到以下错误.
处理路径时出错:product无法读取未定义的属性' replace'TypeError:无法在Object 处读取Object.func(http:// localhost:4200/assets/vendor.js:45832:15)中未定义的属性'replace' .在object.func处的decamelize(http:// localhost:4200/assets/vendor.js:45874:29)的Cache.get(http:// localhost:4200/assets/vendor.js:23421:36)(http: //localhost:4200/assets/vendor.js:45789:12)在Object.dasherize的对象.Cache.get(http:// localhost:4200/assets/vendor.js:23421:36)处(http:// localhost:4200/assets/vendor.js:45878:35)在ember $ data $ lib $ system $ normalize $ model $ name $$ normalizeModelName(http:// localhost:4200/assets/vendor.js:66295:27)在ember $ data $ lib $ serializers $ json $ serializer $$ default.extend.modelNameFromPayloadKey(http:// localhost:4200/assets/vendor. js:75184:67)在Array.map(本机)的ember $ data $ lib $ serializers $ json $ serializer …
我正在尝试渲染余数更多的余烬模型数据1000 records。完成渲染部分将需要2分钟以上的时间。
因此,我有一个计划来对其进行优化。我想100 records在第一次加载第一次。一旦他们走到尽头,那么我需要加载第二个100 records。
我怎样才能做到这一点?