Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing from Single Select to Multiple Select and back again #1560

Closed
thomb opened this issue Sep 17, 2013 · 6 comments
Closed

Changing from Single Select to Multiple Select and back again #1560

thomb opened this issue Sep 17, 2013 · 6 comments

Comments

@thomb
Copy link

thomb commented Sep 17, 2013

I was wondering if it was possible to have Chosen redraw itself after you set "multiple" on the original select element?

I know this is possible if I destroy() the original Chosen select, then trigger Chosen again on the same select, but it would be ideal of this could be picked up by "chosen:updated".

Cheers, and thanks!
Thom

@koenpunt
Copy link
Collaborator

Do you have an actual use case for this kind of behavior? Because I can't think of one..

@thomb
Copy link
Author

thomb commented Sep 22, 2013

My specific use case is a set of three fields: Name, Compare and Value,
where you set up a filter.
Compare can be either a 1-to-1 relation, or 1-to-many.

In the 1-to-many comparison case, I need to be able to select multiple
options from the Value field, but in 1-to-1 Value is only a single option.

Make sense?
On Sep 22, 2013 8:49 AM, "Koen Punt" notifications@github.com wrote:

Do you have an actual use case for this kind of behavior? Because I can't
think of one..


Reply to this email directly or view it on GitHubhttps://github.com//issues/1560#issuecomment-24884510
.

@ngocphamm
Copy link

I'm having the same situation which need a method of "swapping" between single and multiple select list. If you @thomb have figured out a method of doing so, please tell me. :)

@thomb
Copy link
Author

thomb commented Feb 10, 2014

I ended up writing a wrapper for the library, wherein if I needed to switch
between single and multiple select it would redraw the select with multiple
set to true, and then calling .chosen() on the new select.

Not super pretty, but it works.
On Feb 9, 2014 10:09 PM, "Ngoc Pham" notifications@github.com wrote:

I'm having the same situation which need a method of "swapping" between
single and multiple select list. If you @thomb https://github.com/thombhave figured out a method of doing so, please tell me. :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/1560#issuecomment-34603247
.

@ngocphamm
Copy link

It's nice to hear that you found a way through it. I think I tried this method but it didn't work for me. I am using Joomla 3.x with Chosen integrated, so there might be something else that messed it up. Thank you for sharing your problem!

@pfiller
Copy link
Contributor

pfiller commented Jun 4, 2016

The HTML between a single and multiple Chosen select are quite different and there's no good way to switch them back and forth. I don't think there's ever going to be a better way to do this than destroying Chosen and calling it on the select after the switch. Closing!

@pfiller pfiller closed this as completed Jun 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants