can't set value programmatically for single select2

33 views
Skip to first unread message

jenny

unread,
Feb 17, 2017, 5:38:21 AM2/17/17
to select2
I use select2 in the wordpress ACF plugin. After a lot of trial and error I managed to set a value for a MULTIPLE select list programmatically:

$('#mymultiplelist-input').select2("data", [{id: var1, text: var2}]);

However, I can't now set the value for a SINGLE select list.

This doesn't work:

$('#mysinglelist-input').select2("data", [{id: var1, text: var2}]);

Nor does this:

$('#mysinglelist-input').val("Germany").trigger("change");

Can any help?

Thanks!

Reply all
Reply to author
Forward
0 new messages