我正在使用RESTAdapter的ember-data。
我有一个旅游模块:
DS.Model.extend({ title: DS.attr('string'), trips: DS.hasMany('trip') });这是用REST json填充的:
[{ id: 132, title: 'Tour title', },...]和Trips的模块:
DS.Model.extend({ tour: DS.belongsTo('tour'), startDate: DS.attr('date') });这是用REST json填充的:
{ id: 12345, tour_id: 132, startDate: '2013-01-01', }我想这样,当使用旅行模型时,我可以打电话给trip.tour.title来获得旅行的标题。 分别我可以制作tour.trips以获得所有旅行的列表。
但不知何故,这不起作用任何关系用法甚至不会触发ajax请求。 所以我想知道为什么? 所有属性都已正确映射,但不是关系。
请指教。
I am using ember-data with RESTAdapter.
I have a module for Tours:
DS.Model.extend({ title: DS.attr('string'), trips: DS.hasMany('trip') });this is populated with REST json:
[{ id: 132, title: 'Tour title', },...]and a module for Trips:
DS.Model.extend({ tour: DS.belongsTo('tour'), startDate: DS.attr('date') });this is populated with REST json:
{ id: 12345, tour_id: 132, startDate: '2013-01-01', }I would like so that that when using trip model I could call trip.tour.title to get a title of the tour. And respectively I could make tour.trips to get a list of all trips for the tour.
But somehow this is not working any relationships usage don't even trigger an ajax request. So I wonder why? All the properties are mapped correctly, but not relationships.
Please advice.
最满意答案
好像它是这个库的旧版本,这已不相关了。
Seems like it was an old version of this libs, this is not relevant anymore.
更多推荐
发布评论