0

aria-autocomplete と twitter/bloodhound typeahead を実装しました。

問題:値を取得するという意味で部分的に機能していますが、自動的に選択されるようにしたいです。メンバー ID を入力すると、下の div と非表示のテキスト ボックス (ユーザーが次の画面に移動できるようにする前に、後で値があるかどうかがチェックされます) で名前が自動的に選択されます。

私が試したこと: 私は以下を読みました:

https://msdn.microsoft.com/en-us/ie/hh968240(v=vs.94) https://www.w3.org/TR/wai-aria-practices/examples/combobox/aria1.1pattern/ listbox-combo.html

次に、「aria-autocomplete」:「list」を「both」と「inline」に変更しましたが、どちらも影響しませんでした。

次に、テキストボックスをオートコンプリート オフからオートコンプリート オンに変更しましたが、効果はありません。

次に、タイプアヘッドについて読みましたが、オートコンプリートが影響を与えない理由がわかりません。そのためのコードは次のとおりです。

.

displayKey: function (item) { return item.Subscriber_ID },
            templates: {
                //Template to show if there are no results
                empty: function (context) {
                    //  console.log(1) // put here your code when result not found
                    $(".tt-dataset").text('No Results Found');
                },
                suggestion: function (item) {
                    return '<div class=""> ' + item.First_Name + " " + item.Last_Name + '</div>';
                }
            }
        })

.

4

1 に答える 1

0

クリック後に表示するのではなく、c# が表示する必要がある TextBox を追加するために、提案関数にいくつかのコードを追加することでこれを解決しました。

 $('#suggestionName').val(item.First_Name + " " + item.Last_Name);        //used to check whether there is a value when hitting submit (hidden field)      
                $('#divDisplayMemberName').html(item.First_Name + " " + item.Last_Name); //displays it in a <p> tag underneath the TextBox
                return '<div class=""> ' + item.First_Name + " " + item.Last_Name + '</div>'; //displays the actual suggestion
于 2018-09-27T16:28:26.033 に答える