SO - 15174635
by Arun P Johny
HTML
<link rel="stylesheet" href="http://ivaynberg.github.com/select2/select2-3.3.1/select2.css">
<script src="http://ivaynberg.github.com/select2/select2-3.3.1/select2.js"></script>
<input id="postcodes" style="width: 200px"/>
JavaScript
$("#postcodes").select2({
placeholder : "Search for a postcode",
multiple : true,
minimumInputLength : 1,
data:[],
initSelection : function (element, callback) {
var data = [{id:1,text:'bug'},{id:2,text:'duplicate'}];
callback(data);
}
}).select2('val', ['1', '2']);