1

I use select 2 (v4.0) with an ajax option and it works well.

Is there any possibility to programmatically set the selected value of the select (without user click and search)?

UPDATE

Currently I am doing reinit of select2 with initSelection option, but maybe there is another way to do that

Cœur
  • 37,241
  • 25
  • 195
  • 267
Eddie
  • 1,436
  • 5
  • 24
  • 42
  • possible duplicate of [Select2 4.0.0 initial value with Ajax](http://stackoverflow.com/questions/30316586/select2-4-0-0-initial-value-with-ajax) – Kevin Brown-Silva May 26 '15 at 14:03
  • I didn't find a solution in that question. creating `option` and triggering `change` event doesn't work on select2 4.0. – Eddie May 26 '15 at 14:51
  • Please share some code that you are currently using then ([Stack Snippets preferred](https://stackoverflow.com/tags/jquery-select2/info)), so we can help determine what the issue is. – Kevin Brown-Silva May 26 '15 at 19:03
  • I am using standart `select2({ ajax: ... })` init. I tried `$select.append($option).trigger('change');` and other possible solutions and they do not work. The only way I found is to call init method with all options every time I need to add value to the select programmatically. – Eddie May 27 '15 at 08:44

0 Answers0