【问题标题】:aria-autocomplete / typeahead not auto selectingaria-autocomplete / typeahead 不是自动选择
【发布时间】:2018-09-26 21:29:19
【问题描述】:

我已经实现了 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>';
                }
            }
        })

.

【问题讨论】:

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


    【解决方案1】:

    我通过在建议函数中添加一些代码来解决这个问题,添加一个 c# 应该查看的文本框,而不是在单击后查看它:

     $('#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
    

    【讨论】:

      猜你喜欢
      • 2016-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多