ember-data fixtureAdapter嵌入式hasMany [英] ember-data fixtureAdapter with embedded hasMany

查看:80
本文介绍了ember-data fixtureAdapter嵌入式hasMany的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这个几个小时,摆弄了许多不同的组合,以使这项工作得以实现。

I've been at this for a couple hours, fiddling with a number of different combinations to get this working.

LO.List = DS.Model.extend({
  name: DS.attr('string'),
  listItems: DS.hasMany('LO.ListItem', { embedded: true })
});

var lists = LO.store.findAll(LO.List),
    firstList = lists.objectAt(0),
    listItems = firstList.get('listItems'),
    firstListItemId = listItems.objectAt(0).get('id');

console.log(firstListItemId) // [object Object]

< a href =http://jsfiddle.net/65eRS/21/ =nofollow> http://jsfiddle.net/pjmorse/65eRS/

似乎嵌入式选项根本不起作用(我似乎也不会在源文件中找到任何记录,但文档仍然使用它)。我无法找到正确的选项在这里使用(或者如果它正在工作)。任何人都知道我可以在哪里找到这个工作?

It seems that the 'embedded' option is not working at all (I can't seem to find any record of it in the source either, but the documentation still says to use it). I haven't been able to find out the correct option to use here (or if it's working at all). Anyone know where I can look to get this working?

感谢您的帮助!

推荐答案

Ember数据已经取消了对嵌入式数据的支持。我几乎可以肯定这是暂时的,并且会说它应该被带回到lib中作为适配器关注。

Ember-data has removed support for embedded data. I'm almost certain that this is temporary, and would say that it should be brought back into the lib as an adapter concern.

同时,使用这个相当难看的 hasManyEmbedded shim 作为只读嵌入式关联的停顿。

In the mean time, feel free to use this rather ugly hasManyEmbedded shim I wrote as a stopgap for read-only embedded associations.

listItems: DS.hasManyEmbedded('LO.ListItem')

这是一个使用此垫片的小提琴的叉子

这篇关于ember-data fixtureAdapter嵌入式hasMany的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆