I use remote data source for options. When I load form data from server, it only contains the values of select elements. In such situation, select2 does not know the corresponding text to show to user. Is there any built-in reusable mechanism for this common scenario?
How to set the currently selected value/text when data are fetched using ajax?
$('select#test').select2({
ajax: {
url: "user/combo",
dataType: 'json',
delay: 250,
cache: true
}
});
}
}
Indeed, I am trying to create an angular directive as follow:
app.directive('mehrUserCombo', ['$http', function ($http) {
return {
link: function (scope, element, attr) {
element.select2({
ajax: {
url: "user/combo",
dataType: 'json',
delay: 250,
cache: true
}
});
}
}