Update Select2 value, when "original" select control value changed

1,209 views
Skip to first unread message

penyo...@gmail.com

unread,
Jan 20, 2015, 3:49:35 AM1/20/15
to sel...@googlegroups.com
Hello,

Is there an option (any background thread/"watcher"), which will update select2 value, when "original" select control value change, but without calling .trigger("change") to original element?

Example:
I have a dropdown with id="gender", with attached select2 to it.
When I change from code gender's value (e.g. $("#gender").val("1"); ) without calling $("#gender").trigger("change"); I want to update select2 selected value.

I previewed the examples for version 3.5.2 and the only one which can help me is this: http://select2.github.io/select2/#event_ext_change
but there change event is triggered. I don't want to trigger "change" event...

Thanks!

cskar...@gmail.com

unread,
Jan 27, 2015, 6:58:51 AM1/27/15
to sel...@googlegroups.com, penyo...@gmail.com
Hello,
Did you find anything, to fix this?
If yes please let me know because I have the same issue.

Thanks in advance!

Kevin Brown

unread,
Jan 27, 2015, 4:15:41 PM1/27/15
to sel...@googlegroups.com
Hi,

Unfortunately this is not possible and likely won't be supported in the
future. Select2 needs the `change` event to know when the underlying
element has changed. The `change` event is pretty standard, and browser
controls usually emit it when the value has changed, which is why
Select2 uses it.

If you are running into situations where you need to both emit and catch
the `change` event, I would recommend looking into debouncing your
methods so they are only called when you want them to be.

--
Kevin Brown

https://kevinbrown.in
https://github.com/kevin-brown

Ali Shan Backlinks

unread,
Dec 20, 2025, 6:10:05 PM (yesterday) Dec 20
to select2

This is a common Select2 limitation, since it relies on the native change event to stay in sync with the original select element. Without triggering change, Select2 won’t automatically refresh its state, so understanding this behavior early can save debugging time and prevent unnecessary performance or GPU bottleneck issues in larger forms.

Reply all
Reply to author
Forward
0 new messages