vendredi 8 mai 2015

Ember.Select throwing Error in #each helper

I've been wrestling with the for longer than I care to admit. I am trying to load some data from a local store, set the returned value as my model at the route layer, and then render an Ember.Select using that content. Pretty simple stuff right?

Here's my route, where I am loading the data:

App.IdentityRoute = Ember.Route.extend({
  model: function() {
    return new Promise(function(resolve, reject) {
      MuttrChat.models.Identity.find({}, function(err, results) {
        if (err) {
          return reject(err);
        }

        resolve({ identities: results });
      });
    });
  },
  actions: {
    ready: function() {
      this.transitionTo('inboxes');
    }
  }
});

Okay, great, this works. My controller doesn't contain anything relevant to the question (just an action), so I'll spare you the death by syntax-highlighting. Here's the snippet from my template I am trying to render:

{{#if model.identities}}
  <li>
    {{view 'select' classNames='topcoat-select' content=model.identities value=selectedIdentity size=6 optionValuePath='content.userID'}}
  </li>
{{/if}}

If the results from the query are empty (i.e. this block does not run), everything is fine, however when I have results (which is the whole point), Ember throws, giving me:

Error: Assertion Failed: The value that #each loops over must be an Array. You passed [[object Object],[object Object]]

This is driving me nuts, since that's clearly an array! I've tried all kinds of ugly hacks using Ember.A and Ember.ArrayProxy, but they all eventually lead the that same error.

Any help here is greatly appreciated.




Aucun commentaire:

Enregistrer un commentaire