How to reset option values in Select2?

6,723 views
Skip to first unread message

hidoutl...@gmail.com

unread,
Mar 21, 2014, 1:35:58 PM3/21/14
to sel...@googlegroups.com
How to get "remove all options" to work in Select2 when an option in first box is changed?
It works outside the Select2.

http://jsfiddle.net/bond1126/ceRdH/

I've tried everything that was suggested but to no avail.

Please help. Thanks.

Kevin Brown

unread,
Mar 21, 2014, 2:09:10 PM3/21/14
to sel...@googlegroups.com
Part of the issue that you are hitting is that your select is using a
blank value for the placeholder, something which Select2 handles as a
special case with it's own placeholder support. You can get around this
by clearing the value using `select2("val", "", false)` and using
Select2's placeholder support, as shown in this jsfiddle:

http://jsfiddle.net/ceRdH/1/

--
Kevin Brown

Common Sense

unread,
Mar 21, 2014, 2:32:58 PM3/21/14
to sel...@googlegroups.com
Thank you so much. Didn't think it would be that easy. I appreciate your help.
Message has been deleted

Kevin Brown

unread,
Mar 21, 2014, 9:20:17 PM3/21/14
to sel...@googlegroups.com
The arrows are pulled from an image, which isn't in the same directory as your css file. Most likely the css file you are referencing elsewhere has the images in the same directory, but the jsfiddle does not. You can fix this by changing the location of your select2.png file within your css to point to a known location.
-- 
Kevin Brown
On 03/21/2014 05:42 PM, Common Sense wrote:
Kevin,

As you can see the boxes are without arrows.
Do you know how to get those arrows back in place? 
Just wondering, why they are showing in my editor but not in fiddle.

Thank you in advance.

Tom


On Friday, March 21, 2014 2:09:10 PM UTC-4, Kevin Brown wrote:
--
You received this message because you are subscribed to the Google Groups "select2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to select2+u...@googlegroups.com.
To post to this group, send email to sel...@googlegroups.com.
Visit this group at http://groups.google.com/group/select2.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages