option 1: you can directly use the objectdata
var results = [];
$("#individualsfront").select2({
multiple: true,
query: function (query){
var data = {results: []};
$.each(yuyu, function(){
if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
data.results.push({id: this.id, text: this.text });
}
});
results = data.results;
query.callback(data);
}
});
and use it as follows:
$('#individualsfront').on('open',function(){
$.each(results, function(key,value){
console.log("text:"+value.text);
});
});
2: () - :
$('#individualsfront').on('open',function(){
$(".select2-result-label").each(function()
{
console.log($(this).text());
})
});
});
http://jsfiddle.net/ouadie/qfchH/1/
3: .select2("data");, , .
var arrObj = $("#individualsfront").select2("data");
for each(yuyu in arrObj)
{
console.log("id: "+yuyu.id+ ", value: "+yuyu.text);
}
a >