Respect optionValuePath when multiple#59
Respect optionValuePath when multiple#59HeroicEric wants to merge 1 commit intomiguelcobain:masterfrom
Conversation
|
This an interesting topic.
The idea is that #16 has some interesting research on the topic. Specifically:
One of this project's goal is to be completely interchangeable with Ember.Select (although not necessarily in very rigid way). So, selecting multiple tag ids would be like: Selecting entire tag objects would be like: On a separate note, we need to have |
|
OK, cool. I agree that it would be best to try to stay interchangeable with While using So, would you still be open to a PR that adds support for |
|
You mean that Ember.Select doesn't support value when multiple = true? No, it doesn't support.
It wouldn't be interchangeable, yes, but what I meant from that is "someone that goes from Ember.Select to ember-selectize will get things working". I would be very grateful for such a PR. 😃 |
And so would I! I have to do this all the time, and I'm always going in circles figuring out how to do it.. |
|
Maybe: or Either way, setting the |
|
@miguelcobain, @HeroicEric is there any other way in the existing version to get it working? looks like it could take some time for this PR to be merged. |
|
If you're looking for a way to have values: Ember.computed.mapBy('model.someArray', 'id')where
Of course, this would be the way to go. :) |
|
and it will be like |
|
|
This adds support for
optionValuePathwhenmultiple: true.Use Case
I often want to have a select that is populated with Ember Data objects but only care about selecting one of their values, such as their
id. This is especially useful when using a select as a way of populating query params.For example, imagine you have a search controller:
The value for
tagscomes from a collection of Ember Data objects set in the route:Your API might expect to receive an array of tag ids in the query params. To support this, you'd want to add something like the following to the search template:
This could also be handled by adding an observer to set the
tagIdswhenever thetagsarray changes but that adds up really quickly when there are a lot of these on one page and, IMO is a much less elegant solution.TL;DR;
It's confusing and limiting that setting the
optionValuePathis not respected by ember-selectize. If you want to select the entire object rather than one of its properties, you can simply not specify anoptionValuePathor specify'content'as its value.