I'm using select2
in place of search box.
Here i'm using to load countries values like this
$("#countries").select2({
multiple: true,
tags:["India", "Japan", "Australia","Singapore"],
tokenSeparators: [","]
});
When i press save button, they are properly submitted to the server, now here the question is when i want to modify the country field after saving to server, how i can load the saved values to the country field.
This is how i retrieve data from server
$.getJSON('/dataprovider?data=fetchCountriesForm', function(opts) {
//the opts here contains the json values of the countries.
//what code should be written here to load the values in $('#countries).select2();
//user can add some more countries or can remove the previously added countries.
}