on_select method not working when selecting suggestion from list
Closed this issue · 4 comments
Greetings,
Based on the example for remote source example, the on_select method, when selecting a suggestion from the list, is not executed.
my question is: how can i check the selected suggestion?
using the example from lib's webpage, i made it like this:
$scope.ac_option_remote = { suggest: suggest_state_remote, on_error: console.log, on_select: function (selected) { $scope.selected_user = selected.data; console.log($scope.selected_user); } };
The console.log
written, is not showing in developer console (im using gooogle chrome for testing).
edit: im thinking this is not a bug, but posting here could give me some lights about the possible issue.
best regards
Hey,
There is no reason for on_select not to be executed when the source is remote.
If you could share the example (via jsfiddle, plunker, jsbin) I could take a look.
I have the same issue. Sometimes on_selected not executed when click perform in a random place. The rates of fails is around 1-5%. I think there are some problems with ui click event. The rates of fails increase when I use a div element for the label.
This is my code:
var suggest_assets = function(term) {
var q = term.toLowerCase().trim(), results = [];
if (q.length < 2) return [];
var params = { search: q, fields: 'id,assetNo,assetName,serialNo,computerName,assetLocationId'};
var params = {
fiql: 'assetName==*' + q + '*,assetNo==*' + q + '*',
fields: 'id,assetNo,assetName,serialNo,computerName,assetLocationId',
limit: 200
};
results = services.getByParams(variables.crudPath.assetdetails, params).then(function(res){
var assetList = res.data.data;
var o = [];
for (var i = 0; i < assetList.length; i++) {
var asset = assetList[i];
o.push({
value : asset.assetNo,
obj : asset,
label : $sce.trustAsHtml(
'<p><strong> ' + highlight(asset.assetNo,term) + '</strong></p>' +
'<p>' + asset.assetName + '</p>'
)
});
}
return o;
}, function(res) {
if (variables.env === 'dev') console.log(res);
});
return results;
};
$scope.ac_options = {
debounce_suggest: 700
};
$scope.ac_assets = {
suggest: suggest_assets,
on_error: console.log,
on_select: function (selected) {
if ($scope.transaction) {
$scope.transaction.assetId = selected.obj.id;
$scope.transaction.computerName = selected.obj.computerName;
$scope.transaction.assetLocationId = selected.obj.assetLocationId;
} else {
$scope.transaction = {
assetId : selected.obj.id,
computerName : selected.obj.computerName,
assetLocationId : selected.obj.assetLocationId
};
}
}
};