select2 on click option code example
Example 1: select2.org events
$('#mySelect2').on('select2:select', function (e) {
var data = e.params.data;
console.log(data);
});
Example 2: select2 replace options
var options = [];
$.each(dataReturn, function (i, obj) {
//console.log(i);
//console.log(obj);
options.push({
text: obj.NickName,
id: obj.NickName
});
})
$("#BeneType").empty().select2({
data: options
});