thanks
Activate jQuery autocomplete on focus « home
posted on 20:29 - 13 January 2011 | posted by Lev
last modified on 20:31 - 13 January 2011 | last modified by Lev
I'm kind of surprised it took a little researching to get something this simple working as expected, but it seems as though jQuery's autocomplete UI feature won't automatically show you the default options (even if minLength is set to 0) unless the user hits some key in the field (even if focused).
I did some research and at first this was the best I found:
Unfortunately, this approach seems to have a caveat (at least for me on jQuery UI 1.8.7) - it only works the first time you place focus on the field. Oddly enough, the trigger is actually happening each subsequent time the field is focused, the auto-complete tool only pops up the first time.
Without rambling on too much, I'll show you what I came up with which works flawlessly each and every time the field is focused:
JAVASCRIPT CODE
$('selector').autocomplete
({
minLength: 0,
source: function (t, r)
{
// get list here
}
})
.focus
(
function()
{
if (this.value == "")
{
$(this).autocomplete('search', '');
}
}
);
({
minLength: 0,
source: function (t, r)
{
// get list here
}
})
.focus
(
function()
{
if (this.value == "")
{
$(this).autocomplete('search', '');
}
}
);
I hope this helps someone! :)
genial
posted by: guest 186.162.28.46 · date: 20:38 - 18 May 2012
Perfect
posted by: guest 202.160.118.225 · date: 22:25 - 29 February 2012
works
posted by: guest 85.23.204.16 · date: 12:06 - 21 September 2011
It helped me very much.
posted by: guest 217.92.109.222 · date: 16:06 - 05 August 2011
Thanks
posted by: guest 137.122.14.20 · date: 21:22 - 13 July 2011
untitled
posted by: guest 96.245.82.106 · date: 4:18 - 28 February 2011
Related Items »
- documentation » Controlling the AJAX refresh times
- home » A really interesting quirk with AJAX & mySQL
- home » Update regarding 1.0.0b5
- home » Theia's improved avatar manager
- videos » Theia in-browser avatar cropping
- home » Firefox 3 goes 1 pixel out of bounds with jquery, scrollTop and height()
- home » Having trouble with Jquery's dialog('isOpen') ?
- videos » Theia - control panel management (end-user)
- requests » auto-complete cache deleting tool
- home » jQuery's outerHeight() method with margin argument






