[jQuery] jquery-autocompete - have a 'clearing' focus handler on textfield
Hello all,
I have a text field that is using an autocomplete as seen here:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
I am having trouble clearing the textfield when user first enters the
field.
$j("#clientName").result(function(event, data, formatted)
{
$j("#clientID").val( data[0] );
});
$j("#clientName").focus(function() //clear the textfield when user
(re)enters info
{
$j("#clientID").val( "" );
$j("#clientName").val( "" );
});
But when user click mouse on autocomplete list, the plugin I think is
smart and returns the focus back to the field, which unfortunately
clears the textfield and the hidden input clientID it sets. So when
the user enters the textfield it clears it, but when he gets done
choosing a list option (with his mouse), it calls focus again. and
clears the autocompleted answer.
Anyone got a good solution to this? I tried hack solutions with
blurring the textfield in the .result(doesnt matter since focus is
called before .result), setTimeouts, setting and checking global vars,
etc, got nothing in my sleeve other than modifying wherever the code
is called.
Anyone got any ideas?
Thanks,
Ari