2

これに対する答えを求めて蜘蛛の巣をトロールしたので、私は乾いてきました。

以下の関数の目的は、オートコンプリートテキストボックスに、テキストの視覚補助を含むが、値をバッキングする値を入力できるようにすることです。フォーム内のMVCコントローラーに投稿するときに、これらを複雑なオブジェクトにバインドする必要があります。

多数の隠しフィールドを使用する以外に、必要なものを実現する方法はありますか?

 $("#addressString")
                .autocomplete({
                    source: function (request, response) {
                        $.ajax({
                            url: '/Send/Send/GetAddressBook',
                            type: "POST",
                            dataType: "json",
                            data: { query: extractLast(request.term), groupName: $('#SelectGroupName').val() },
                            term: extractLast(request.term),
                            success: function (data) {
                                response($.map(data, function (item) {
                                    return {
                                        label: item.label,
                                        value: item.label,
                                        id: item.id,
                                        type: item.type
                                    };
                                }));
                            }
                        });
                    },
                    search: function () {
                        var term = extractLast(this.value);
                        if (term.length < 1) {
                            return false;
                        }
                        return true;
                    },
                    focus: function () {
                        return false;
                    },
                    select: function (event, ui) {
                        var terms = split(this.value);
                        terms.pop();
                        terms.push(ui.item.value);
                        terms.push("");
                        this.value = terms.join("; ");
                        return false;
                    }
                });
        });
4

0 に答える 0