C# jQueryUI自动完成id值

C# jQueryUI自动完成id值,c#,asp.net-mvc,jquery-ui,razor,autocomplete,C#,Asp.net Mvc,Jquery Ui,Razor,Autocomplete,如何在jQueryUI Autocomplete中获取另一个字段(如Id),而不是标记自身? (在MVC Razor中) 我使用了自动完成,它可以工作,但我希望在标签之外还有一个字段(或者多个字段)。在标记中: <input type="text" class="item" id="input_autocomplete_1" custom_attr="XXX" /> 你能提供更多的细节吗?当用户选择一个值时,是否希望id在input中?我有一个输入。使用autocomplete我可

如何在jQueryUI Autocomplete中获取另一个字段(如Id),而不是标记自身? (在MVC Razor中)

我使用了
自动完成
,它可以工作,但我希望在标签之外还有一个字段(或者多个字段)。

在标记中:

<input type="text" class="item" id="input_autocomplete_1" custom_attr="XXX" />

你能提供更多的细节吗?当用户选择一个值时,是否希望
id
input
中?我有一个输入。使用
autocomplete
我可以为搜索结果设置一个标签(如
BookTitle
),但我可以在结果中获得另一个字段,如
BookId
     $('.item').autocomplete({
                    source: function( request, response ) {
//to send the custom attribute to the populate function
                        customAttr = this.element.attr('custom_attr');
                        $.ajax({
                            url: "",
                            dataType: "json",
                            data: {
                                term : request.term,
                                custom_attr: customAttr 
                            },
                            success: function( data ) {
//return a json with label, id and custom
                                response( $.map( data, function( item ) {
                                    return {
                                        label: item.label,
                                        id: item.id,
                                        custom: item.custom
                                    }
                                }));
                            }
                        });
                    },
                    select: function( event, ui ) {
//if you want to do something when the item is selected
                       //you can access:
                       //ui.item.id;
                       //ui.item.custom; 
                    }
                });