I have been using Select2 4.0.0-rc.1 for a couple of weeks (using the ajax
adapter) and I am trying to find a way to "push" data after it has been initialized.
Within the dropdown list, I have the choice to
- select an entry in the list (using
ajax
) - add a free entry (using
createTag
) - add a new entry
If I select "add a new entry", I can fill out a form, and once saved, the new data must be shown as a selected entry.
If I push data using select2_existing.select2( { data: data } ).val( 4 );
it works, but ajax
call does not work anymore.
I have then to
- destroy select2
- re-create it
Which will then allow me to have my new data and ajax
adapter working.
It is possible to do this without the create->data->destroy->create cycle?