Relation is DS.PromiseMany instead model and data

本小妞迷上赌 提交于 2019-12-12 06:09:24

问题


What I need is: 1) Represent list of partners

App.Partner= DS.Model.extend(
    {
        name: attr(),
        site: attr(),
        contacts: DS.hasMany('partner-contact', { async: true, polymorphic: true })
    }
);

2) and names of partners contacts

App.PartnerContact = DS.Model.extend(
    {
        name: attr(),
        phone: attr(),
        post: attr(),
        email: attr(),
        partnerId: attr(),
        partner: DS.belongsTo('partner')
    }
);

So I have route:

App.CallsMyContactsRoute = Ember.Route.extend({
    //needs: "partner-contacts",
    model: function () {
        return this.store.find('partner');  
    }
});

And template:

{{#each partner in model}}
        <tr class="gradeA even" role="row">
            <td class="sorting_1">{{partner.name}}</td>
            <td>{{partner.name}}</td>
            <td>{{partner.phone}}</td>
            <td class="center">

                {{partner.contacts}}
            {{#each contact in partner.contacts}}
                {{contact.name}}
            {{/each}}
            </td>
            <td class="center">A</td>
        </tr>
    {{/each}}

But {{partner.contacts}} is DS.PromiseManyArray And it ever doesn't make a query to server.

Answer from server (Partners)

{  
   "Partner":[  
      {  
         "id":4,
         "name":"CompanyNamej",
         "site":"www.no-site.ru"
      },
      {  
         "id":13,
         "name":"test",
         "site":"sdasdasd"
      },
      {  
         "id":14,
         "name":"",
         "site":""
      }
   ]
}

What is the problem?

DEBUG: Ember      : 1.10.0
vendor.js:16928DEBUG: Ember Data : 1.0.0-beta.15
vendor.js:16928DEBUG: jQuery     : 2.1.3

来源:https://stackoverflow.com/questions/29213984/relation-is-ds-promisemany-instead-model-and-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!