0

複数のオートコンプリートプラグインが必要なページがあります。クラスセレクターを使用してオートコンプリートコードを初期化したいのですが。私の問題は、そのコード内で、トリガーされた要素のIDを選択できる必要があるということです。それを行う方法はありますか?

//class selected input
$(".autocomplete-class").autocomplete({
    autoSelect: true,
    autoFocus: true,
    delay: 200,
    source: function (request, response) {
        $.ajax({
            url: "/Country/Find", type: "GET", dataType: "json",
            data: { search: request.term, maxResults: 10 },
            success: function (data) {
                if (data.length == 0) {
                    var test = $(this);
                    $(/* ID of the input */).val(function (index, value) {
                        return value.substr(0, value.length - 1);
                    })
                    $(/* ID of the input */).autocomplete("search");
                }
                response($.map(data, function (item) {
                    return { label: item, value: item }
                }))
            }
        })
    }
});
4

0 に答える 0