2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-12-27 12:32:36 +00:00

Deselect active element when mouse leaves suggestions container

This commit is contained in:
Tomas Kirda 2013-01-20 14:36:27 -06:00
parent 56437a2ec5
commit 2afb5fc517

View File

@ -141,6 +141,7 @@
initialize: function () {
var that = this,
suggestionSelector = '.' + that.classes.suggestion,
selected = that.classes.selected,
container;
// Remove autocomplete attribute to prevent native suggestions:
@ -169,6 +170,12 @@
that.activate($(this).data('index'));
});
// Deselect active element when mouse leaves suggestions container:
container.on('mouseout', function() {
that.selectedIndex = -1;
container.children('.' + selected).removeClass(selected);
});
// Listen for click event on suggestions list:
container.on('click', suggestionSelector, function () {
that.select($(this).data('index'));