You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If using multiple with custom query it's llosing selection.
in getSelection You call custom query function to fetch options. But often those option are defferent because of ajax. and earlier selected options are gone.
That's why You have to store previous selection
Change:
function getSelection(callback) {
if (isMultiple) {
getOptions(function (options) {
var selection = [];
for (var i = 0; i < options.length; i++) {
var option = options[i];
var viewValue = controller.$viewValue || [];
if (viewValue.indexOf(option.id) > -1) {
selection.push(option);
}
}
callback(selection);
});
} else {
getOptions(function () {
callback(optionItems[controller.$viewValue] || {obj: {}});
});
}
}
To:
var previousSelection = [];
function getSelection(callback) {
if (isMultiple) {
getOptions(function (options) {
var selection = [];
options = options.concat(previousSelection || []);
for (var i = 0; i < options.length; i++) {
var option = options[i];
var viewValue = controller.$viewValue || [];
if (viewValue.indexOf(option.id) > -1) {
selection.push(option);
}
}
previousSelection = angular.copy(selection);
callback(selection);
});
} else {
getOptions(function () {
callback(optionItems[controller.$viewValue] || {obj: {}});
});
}
}
The text was updated successfully, but these errors were encountered:
If using multiple with custom query it's llosing selection.
in
getSelection
You call custom query function to fetch options. But often those option are defferent because of ajax. and earlier selected options are gone.That's why You have to store previous selection
Change:
To:
The text was updated successfully, but these errors were encountered: