2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-09 23:01:00 +00:00

Deselect active element when mouse leaves suggestions container. Fixes #26

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

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'));