jQuery UI Autocomplete formating help, (I'm new to jQuery)
- by brant
I can't seem to figure out how to add additional functionality to the basic jquery autocomplete. Returning the json data isn't the problem, it's how I am supposed to use the extra json data that confuses me.
$(function() {
$("#q").autocomplete({
source: "/a_complete.php?sport=<?=$sport?>",
minLength: 2
});
});
Response data:
[{"pos":"SG","url":"\/nba_player_news\/Kobe_Bryant","value":"Kobe Bryant"},{"pos":"C","url":"\/nba_player_news\/Patrick_O'Bryant","value":"Patrick O'Bryant"}]
My goal is something like this:
Kobe Bryant (SG)
I've read what jqueryui autocomplete documentation has to say and I know i need to use formatItem and/or formatResult. I can't seem to put it all together to make this work as it should.
I hope someone with a lot of patience finds the time to help guide me to where I need to go. :)