jeudi 22 octobre 2015

Ember store not working as expected

I'm using ember v1.10 and ember data on an existing project. I have a service that returns an object that has a message string and an array or publishable ids. As follows:

data: [{"Message":"Example 1 cannot be published the following items to be published",
  "PublisherIds":[
    "b9b77872-6954-404f-b451-b5a1938b2fa8",
    "030b39de-5746-4ed4-9e17-e86bb49be164"]
},
{"Message":"Example 2 cannot be published items to be published",
      "PublisherIds":[
        "b9b77872-6954-404f-b451-b5a1938b2fa8",
        "030b39de-5746-4ed4-9e17-e86bb49be164"]
}]

In my controller, I want to iterate through the publisher ids and use them to get all the other data associated with the items from the model called 'publishable' that is already in my store and push them in to an array so I can display them in a table in my template.

My attempt:

        var _this = this;

        data.forEach(function(d){
            var items = [];
            d.PublisherIds.forEach(function(a){
                var temp = _this.store.find('publishable', a);
                d.items.push(temp);
            });

        } );

Unfortunately the store.find doesn't seem to work. I'm not getting the actual records and I can't push them into an array. Any help is appreciated!




Aucun commentaire:

Enregistrer un commentaire