aria-autocomplete /预先输入不会自动选择

时间:2018-09-26 21:29:20

标签: asp.net jquery-ui autocomplete typeahead.js bloodhound

我已经实现了aria-autocomplete和twitter / bloodhound typeahead。

问题:从某种意义上说,它可以检索值,但我希望它能被自动选择。 当我输入会员ID时,我希望它在下面的div和隐藏的文本框中自动选择名称(在允许用户进入下一个屏幕之前,稍后会检查该文本框中是否有值)

我尝试过的事情: 我已阅读以下内容:

http://test.com/private_token=###### https://msdn.microsoft.com/en-us/ie/hh968240(v=vs.94)

然后我将“ 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>';
                }
            }
        })

1 个答案:

答案 0 :(得分: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