Question

I have got this route:

App.PanelRoute = Ember.Route.extend({
model: function(){
    return this.store.find('topology');
}
});

With this view:

<script type='text/x-handlebars' id='panel'>

{{#each}}
  {{#link-to 'details' this}} Details{{/link-to}}
  {{name}}
  {{#each item in site}}
    {{item}}
  {{/each}}
{{/each}}
</script>

This view shows 2 objects, but if I click the details link-to and then the back button, it calls the server again and return a duplicate of the model, then it renders 4 objects, the original 2 and a copy of them. What's going on?

I am using RESTAdapter

App.Topology = DS.Model.extend({
name: DS.attr('string'),
site: DS.attr()
});

topologies:

{"topologies": [
{
"name": "name1",
"site": ["oneplace1","anotherplace1"]
},
{
"name": "name2",
"site": ["oneplace2","anotherplace2"]
}

]}
Was it helpful?

Solution

What version of Ember / Ember Data are you using?

Apart from that you can try using this.store.find('topology');. findAll is a private method so you should not use it.

Update

It looks like your JSON response is lacking an id attribute for each record. Therefore Ember Data can't determine which records are already in the store.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top