Forum

select2, dynamicall...
 
Notifications
Clear all

select2, dynamically insert new value then select it

2 Posty
1 Users
0 Reactions
1,647 Widok
0
Topic starter

how to? ajax, jquery

2 Answers
0
Topic starter
1
2
var newOption = new Option("visible text",id_value, true, true);
$("#my_select").append(newOption).trigger('change');
var newOption = new Option("visible text",id_value, true, true);
$("#my_select").append(newOption).trigger('change');
0
Topic starter

and try this

1
$("#asd").select2('destroy').empty().select2({data: [{id: 1, text: 'new text'}]});
$("#asd").select2('destroy').empty().select2({data: [{id: 1, text: 'new text'}]});

Odpowiedź

Author Name

Author Email

Your question *

 
Preview 0 Revisions Saved
Share: