I need to set an array of data after initializing select2. So I want to make something like this:
var select = $(\'#select\').select2({}); select.data([ {id: 1
In onload:
$.each(data, function(index, value) { $('#selectId').append( '' + data[index].value1 + '' ); });