ken
ken

Reputation: 3745

Ember-data RecordArray isLoaded Status

Can any one explain to me why a RecordArray status isLoaded is set to true before even a success method on an ajax call is called.

From ember-data source code

  findAll: function(store, type, since) {
    var root = this.rootForType(type);

    this.ajax(this.buildURL(root), "GET", {
      data: this.sinceQuery(since),
      success: function(json) {
          debugger;
        Ember.run(this, function(){
          this.didFindAll(store, type, json);
        });
      }
    });
  },

Defined in a view

handler: function() {        
    var content, controller = this.get('controller');
    if(controller.get('content.isLoaded')) {
    }
}.observes('controller.content.isLoaded')

Upvotes: 6

Views: 2195

Answers (2)

segfault.py
segfault.py

Reputation: 133

For anyone using an old version of Ember: I found that if you wrap whatever you're doing with Ember.run.next, content is actually loaded by then.

Not the prettiest solution but it worked for me in Ember v1.0.

Upvotes: 0

ahmacleod
ahmacleod

Reputation: 4310

There appears to be an ongoing bug with isLoaded properties being set prematurely on collections. Here is the relevant issue on GitHub.

Upvotes: 4

Related Questions