asp.net - aria-autocomplete / typeahead 不是自动选择
问题描述
我已经实现了 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”,但都没有影响。
然后,我将文本框从自动完成关闭更改为自动完成,但没有任何效果:
然后我阅读了关于 typeahead 的内容,但我不明白为什么自动完成也没有影响。这是代码:
.
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>';
}
}
})
.
解决方案
我通过向建议函数添加一些代码来解决此问题,以添加 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
推荐阅读
- sql-server - 许多停止和启动设备的许多日期之间的日期差异(工作时间)
- excel - 以不同的时间间隔对时间进行分类
- c# - 我应该如何/在 xaml 中的哪个位置放置一个部分,以便不会为每个标签重复托盘图标?
- mysql - 预期有 4 个值,但找到 33 个。(在位置 300 的“(”附近)
- android - 琥珀色和绿色之间 1 像素宽
- ruby-on-rails - 从日期中减去月份在红宝石中没有给出正确的值吗?
- google-maps - Intent 应包含 Place,但不包含
- drop-down-menu - Oddo - 将选定的树视图记录从向导打印到 pdf
- javascript - 它与 setInterval 和 setTimeout 计时器函数有关,它什么时候开始工作以及函数如何知道他们的工作开始了?
- c++ - 为什么 Eclipse CDT 代码格式化程序有时会在模板参数中引入空格?