select2, dynamically insert new value then select it« Wróć do listy pytań
how to? ajax, jquery
|
▲ ▼ |
and try this
$("#asd").select2('destroy').empty().select2({data: [{id: 1, text: 'new text'}]}); |
▲ ▼ |
var newOption = new Option("visible text",id_value, true, true); $("#my_select").append(newOption).trigger('change'); |