ember-widgets icon indicating copy to clipboard operation
ember-widgets copied to clipboard

Select doesn't work when content is an array of string (dev/master)

Open abuiles opened this issue 10 years ago • 7 comments

When using an array of strings, select doesn't show anything

priority: ['high', 'low']

and {{select-component content=priority selection=taggingPriority}}

See http://cl.ly/image/2S3o3o2f1o1D

abuiles avatar Jul 02 '14 16:07 abuiles

I'm using canary.

abuiles avatar Jul 03 '14 16:07 abuiles

As far as I know, that's the expected behavior: the data bound to the select component should be an array of objects, which might then have "name" and "label" attributes that you can use to separate what's displayed in the UI from what's sent to the backend. For example, our documentation pages and demo JS Bin (http://emberjs.jsbin.com/xabeb/1/edit) uses objects that have both names and country codes.

I was in the same situation as you recently - just wanted to use a simple array of strings - and I agree it would be great to add this as a feature! If you'd like to make the change and submit it as a PR, that would be great. Otherwise I'd recommend using the workaround of making wrapper objects around your priority values.

azirbel avatar Jul 03 '14 21:07 azirbel

@azirbel this used to work fine on previous versions, the issue for this not working was that view is not set on https://github.com/Addepar/ember-widgets/blob/master/src/templates/select_item_layout.hbs when you use an array of strings. I've been using the plugin for a while so changing all my code to have a name attr is not possible right now.

I replace the template with something like the following code and it works fine

{{#if view}}
  {{#if view.content.isGroupOption}}
    {{view.content.name}}
  {{else}}
    {{yield}}
  {{/if}}
{{else}}
  {{yield}}
{{/if}}

abuiles avatar Jul 04 '14 02:07 abuiles

Ok, thanks @abuiles! Didn't realize this used to work. Feel free to make a PR; I'll also take a look when I can, but I'm not sure when I'll get a chance next.

azirbel avatar Jul 04 '14 03:07 azirbel

Actually, my solution partially worked :( I moved to Ember.Select in some scenarios for now.

Adolfo Builes

On Fri, Jul 4, 2014 at 12:53 AM, Alex Zirbel [email protected] wrote:

Ok, thanks @abuiles https://github.com/abuiles! Didn't realize this used to work. Feel free to make a PR; I'll also take a look when I can, but I'm not sure when I'll get a chance next.

— Reply to this email directly or view it on GitHub https://github.com/Addepar/ember-widgets/issues/57#issuecomment-48006954 .

abuiles avatar Jul 04 '14 04:07 abuiles

@azirbel did you guys fix this?

abuiles avatar Jul 29 '14 14:07 abuiles

I'm afraid not =( it's still on the todo list but there's lots to do.

azirbel avatar Jul 29 '14 18:07 azirbel