jQuery UI Autocomplete formating help, (I'm new to jQuery)

Posted by brant on Stack Overflow See other posts from Stack Overflow or by brant
Published on 2010-04-05T21:40:19Z Indexed on 2010/04/05 21:43 UTC
Read the original article Hit count: 310

Filed under:
|
|
|

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. :)

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about autocomplete