I can get this to work...
var options = [{id: 1, text: \'Adair, Charles\'}] $(\'#names\').select2({ data: options, })
But i cant work
Just to add. This also worked for me:
HTML:
Javascript
$('#names').select2(); var options = $('#names'); $.each(sampleArray, function() { options.append($("").val(this.id).text(this.name)); });