[jQuery] [autocomplete] query on focus
Maybe I am missing something, but there doesn't appear to be a way to
make the autocomplete box show up as soon as the input box is
focused. I tried to modify the focus event in the code, but the
result was that the autocomplete box would not go away and the input
box kept focusing itself when another form component was focused.
Here is the code I am using:
$("#medication").autocomplete("/patient/meds/0?box=medication", {
minChars: 2,
autoFill: true,
max: 100
});
$("#dosage").autocomplete("/patient/meds/0?box=dosage", {
minChars: 0,
autoFill: true,
extraParams: {
medication : function() {
return $('#medication').val();
}
}
});
The purpose of the form is to allow a user to first select a
prescription medication, and then the dosage for that medication. /
patient/meds/ is a php script which queries a database for the
possible dosages of the medication. Currently, the user requires to
press a key for the autocomplete box to show up. Ideally, I'd like
the autocomplete box to function as it does now, but if the minChars
option is set to 0, the query will execute when the input is focused.
Any thoughts as to how I can achieve these results?