mirror of
https://github.com/devbridge/jQuery-Autocomplete.git
synced 2024-11-26 14:56:36 +00:00
Deselect active element when mouse leaves suggestions container
This commit is contained in:
parent
56437a2ec5
commit
2afb5fc517
@ -141,6 +141,7 @@
|
|||||||
initialize: function () {
|
initialize: function () {
|
||||||
var that = this,
|
var that = this,
|
||||||
suggestionSelector = '.' + that.classes.suggestion,
|
suggestionSelector = '.' + that.classes.suggestion,
|
||||||
|
selected = that.classes.selected,
|
||||||
container;
|
container;
|
||||||
|
|
||||||
// Remove autocomplete attribute to prevent native suggestions:
|
// Remove autocomplete attribute to prevent native suggestions:
|
||||||
@ -169,6 +170,12 @@
|
|||||||
that.activate($(this).data('index'));
|
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:
|
// Listen for click event on suggestions list:
|
||||||
container.on('click', suggestionSelector, function () {
|
container.on('click', suggestionSelector, function () {
|
||||||
that.select($(this).data('index'));
|
that.select($(this).data('index'));
|
||||||
|
Loading…
Reference in New Issue
Block a user