jquery-autocomplete
jquery-autocomplete copied to clipboard
DIV closes on Scrollbar click
This is a "repost" from someone who submitted it on GoogleCode.
When the following css change is done to put a "scrollbar": .acResults { padding: 0px; border: 1px solid WindowFrame; background-color: Window; overflow-x: hidden; overflow-y: auto; max-height:250px; }
The div closes automatically when clicked on scroll bar in non-FF browsers.
I'm using the latest version as of today.
Here an example of ui-autocomplete where the scroll works: http://jqueryui.com/demos/autocomplete/maxheight.html
this should do the trick: /** * Finish on blur event * Use a timeout because instant blur gives race conditions */
$elem.blur(function() {
if (self.finishOnBlur_) {
$('*').not('.'+this.options.resultsClass).click(function(){
self.deactivate(true);
});
//self.finishTimeout_ = setTimeout(function() { self.deactivate(true); }, 200);
}
});
But what if you blur because of an event that is not a click?
@dyve, @techni7's solution worked for me..
Maybe it should be exposed to the public API as an option..
Anyway thanks!
Unless I am missing something, it only blurs on a click event. I am quite sure there are other reasons for blurring (such as tabbing outside of the autocompleter). It might be so that all these other "blur reasons" are caught elsewhere, but it feels wrong enough to keep this outside of the main code for now.
I would welcome explanations / further research.
I'm confused as to why this is not fixed yet. Any other autocomplete I've used works properly with a scrollbar (jQuery-UI, bassistance.de). The solution posted above doesn't work very well. It works, but clicking outside of the drop-down doesn't close it, and scrolling through the returned values using the cursor keys doesn't scroll when you get to the bottom. I also get "Cannot read property 'resultsClass' of undefined" when clicking back outside the drop-down.