I am using angularjs and autocomplete (jquery-ui). when I select a value from the list of the menu that appear when I write in the textbox, the menu does not disappear. Here the code I am using:
<input type="text" name="indirizzo" data-ng-model="input.indirizzo" auto-complete ui-items="indirizzi" data-ng-model-options="{ updateOn: 'mousedown blur' }" />
Here the directive of angular:
.directive('autoComplete', function($timeout) {
return function(scope, iElement, iAttrs) {
iElement.autocomplete({
source: scope[iAttrs.uiItems],
select: function() {
$timeout(function() {
iElement.trigger('input');
}, 0);
}
});
};
})
Can anyone help me?
Thank you
UPDATE
I see that if I remove the following line from directive, the menu is correctly closed
iElement.trigger('input');
but in this way, my model is not updated.
UPDATE Perhaps I understood which is the problem. But I do not how to solve it. When I trigger the input event, it's like I focus on the input element of the Html. So when I focus on it, the menu is opened again. In fact if I see better, the menù is closed and immediately re-open.
Any suggestion?