I'm in a similar situation a my other problem prevent datepicker from triggering parent mouseleave, but that solution doesn't seem to apply to jQuery UI autocomplete.
How can the hover also apply to autocomplete children? In other words, if one mouseenter
s on an autocomplete suggestion, #hoverMe
should stay open. Also, suggestion/code on how to handle select
ing a selection that's outside of #hoverMe
while keeping #hoverMe
shown until one mouseenter
s back in would be great!
http://jsfiddle.net/Kzp87/
html
<div id="hoverAnchor">hover me</div>
<div id="hoverMe" style="display:none">arbitrary text
<input type="text" id="autocompletor"></div>
</div>
js
$(document).ready(function () {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#autocompletor").autocomplete({
source: availableTags
});
var _enter = false;
$("#hoverAnchor").add($("#hoverMe")).mouseenter(function () {
if (!_enter) {
$("#hoverMe").stop(true, false).animate({
height: 'toggle',
opacity: 'toggle'
}, 200);
}
_enter = true;
}).mouseleave(function () {
_enter = false;
$("#hoverMe").stop(true, false).animate({
height: 'toggle',
opacity: 'toggle'
}, 200);
});
});