each template shows wrong data after loadMany #11

chachonen opened this Issue Dec 23, 2011 · 9 comments


None yet

6 participants


After loading remote data with store.findAll() sometimes the #each template updates with incorrect data, showing the data of the first item in all of the items, even id the controller holds correct data.

<script type="text/x-handlebars">
  {{#each App.records}}
App = Ember.Application.create({ 
    records: [] 

App.serverAdapter = DS.Adapter.create({
    findAll: function(store, type) {
        var url;
        if (type == App.Publication) {
            url = "publications.json";
        }   else {
            url = "posts.json";

          url: url,
          success: function(data){
            // returns from server
            // [{"id":1, "name":"Pub one"},{"id":2, "name":"Pub two"}] // for "publications.json"
                // [{"id":1, "name":"My first post"},{"id":2, "name":"My second post"}]// for "posts.json"
            store.loadMany(type, data);

App.store = DS.Store.create({
    adapter: App.serverAdapter

App.Publication = DS.Model.extend({
    name: DS.attr('string')

App.Post = DS.Model.extend({
    name: DS.attr('string')

App.set('records', App.store.findAll(App.Publication));

Sometimes, I repeat sometimes, the output is:
<p>Pub one</p><p>Pub one</p> when it should be <p>Pub one</p><p>Pub two</p>

EskiMag commented Dec 26, 2011

I am having the same problem.

kamal commented Dec 28, 2011

I'm facing this with a custom adapter and findQuery with modelArray.load


+1 I am having this issue as well

Me too.

@ghempton ghempton added a commit to ghempton/data that referenced this issue Dec 30, 2011
@ghempton ghempton Fixes #11. ContainerView invokes objectAt on the underlying content d…
…uring the arrayDidChange handler. This causes the modelCache in ModelArray to be out of sync. Fix was to change the order of the _super call. In general, this code seems dangerous to update the modelCache in these places.
wycats commented Dec 31, 2011

Yikes! @ghempton's fix should probably resolve this issue. I'll pull it this weekend once we get some test cases (or I write them myself :P )

kamal commented Jan 1, 2012

@ghempton's patch almost fixes it. Now the items display correctly but are not picking up attribute changes set in didChange

wycats commented Jan 1, 2012

@kamal would you mind putting together a JSFiddle that illustrates the issue?

@ghempton ghempton added a commit to ghempton/data that referenced this issue Jan 3, 2012
@ghempton ghempton Added test case for #11. ab5b071
ghempton commented Jan 4, 2012

Another fix I submitted for #21 was just pulled and I think that should fix your issue.

wycats commented Jan 4, 2012


@wycats wycats closed this Jan 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment