On Dec 4, 6:46 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Take a look at the source of this 
> demo:http://dev.jquery.com/view/trunk/plugins/autocomplete/demo/json.html
>

Thanks, that did the job. For future googlers this is what I did:

var data = [ {name:'Jeff', id:'1234'}, {name:'Link', id: '999'} ];

                $().ready(function() {
                        function format(person) {
                        return person.name;
                }

                $("#client_names_autocomplete")
                        .autocomplete(data, {
                                mustMatch: true,
                                autoFill: true,
                                matchContains: false,
                                dataType: "json",
                                parse: function(data) {
                                        return $.map(data, function(row) {
                                                return {
                                                        data: row,
                                                        value: row.name,
                                                        result: row.name + 
"???? <" + row.to + ">"
                                                        }
                                                });
                                        },
                                formatItem: function(item) {
                                        return format(item);
                                }
                        })
                        .result(function(event, item) {
                                //alert(item.id);
                                // this pushes the person ID into a
                                // hidden form input and posts it
                                $("#person_id").attr("value", item.id);
                                document.nav_admin.submit()
                        });
                });

there are a few mysteries that I didn't figure out, but the code works
OK for me :-)

Cheers,

monk.e.boy

Reply via email to