[jQuery] Autocomplete onItemSelect issue
Hi all,
I'm using a modified autocomplete from http://www.pengoworks.com/workshop/jquery/autocomplete.htm
and am having some issues using the onItemSelect option. It works, but
seems to be calling the function once when autocomplete is called to
during $(document).ready.
In the code below, focusFirst is called when the document loads as
well as when an item is selected. This doesn't seem like a desirable
behavior. Does anyone know why this is or how it could be remedied?
Thanks for any help anyone can offer.
-matthaus
Here is some example code:
<link rel="stylesheet" type="text/css" href="./includes/css/
jquery.autocomplete.css" media="all" />
<script src="./includes/javascript/jquery-1.3.2.min.js" type="text/
javascript"></script>
<script src="./includes/javascript/jquery.autocomplete.js" type="text/
javascript"></script>
<script type="text/javascript">
function focusFirst() {
$('#firstSearch').focus();
alert('called');
}
$(document).ready(function() {
$('#firstSearch').autocomplete('handlers/searchHandler.php',
{ mustMatch: 1, onItemSelect: focusFirst, extraParams: {search:
'first'}});
});
</script>
<strong>Search By First Name: </strong><input type="text"
class="search" name="firstSearch" id="firstSearch" />