sukima / ember-cli-select-picker

An enhanced Boostrap styled select component addon for Ember CLI
https://sukima.github.io/ember-cli-select-picker
MIT License
23 stars 15 forks source link

Does not work with response from Ember.Data find/query methods #42

Open dslamba opened 9 years ago

dslamba commented 9 years ago

The response type from those is an RecordArray, which needs a forEach to loop.

IF content property is set to such an array returned from store.find(), it treats it like one object not an array.

jelhan commented 8 years ago

Faced the same issue today. Quick and dirty work-a-round: Use a computed property as content which maps the RecordArray to a normal array. A fix would be great!

sukima commented 8 years ago

To be clear, I've never used Ember.Data. So my understanding of its data schema is a bit limited. Would anyone with a more failure understanding of what Ember.Data wants/expects be willing to experiment a PR? I'm ok entertaining a WIP just to get me started in the right direction.

dslamba commented 8 years ago

I can give it a shot later. Right now you have code that takes the content object and converts it to an array. That conversion, uses a function which treats the response from Ember Data as an object and returns it as an Object. Instead we need to check if object is of the Ember.Enumerable time, if so treat it as an array.

Also, will need to loop over the content array using forEach instead of the (var i = 0; i < X.length) syntax.

sukima commented 8 years ago

So my script uses map which is an Array function which Ember.Enumerable has. However to be safe with what comes in I wrap the content with Ember.makeArray() which in turn tests the object with Ember.isArray() does an Ember.Enumerable not respond true with makeArray()?