gpt4 book ai didi

javascript - 在焦点自动完成中选择多个值

转载 作者:行者123 更新时间:2023-12-02 17:48:45 25 4
gpt4 key购买 nike

我已经使用 jQuery UI 实现了多个值的自动完成。它工作正常,但问题是我不想从下拉列表中显式选择值(使用选项卡)。我的要求是,当我浏览下拉菜单时,我的搜索框应该被填充。然后我进入昏迷状态并再次从下拉列表中继续搜索。

我基本上尝试了 jqueryUI Autocomplete 中的代码片段,但焦点已被抑制。我想要的是,我们应该能够使用焦点选择它,然后给出逗号并继续搜索,而不是选择选项卡上的项目。

.autocomplete({
minLength: 0,
source: function( request, response ) {
// delegate back to autocomplete, but extract the last term
response( $.ui.autocomplete.filter(productNames, extractLast(request.term)));
},

focus: function() {
// prevent value inserted on focus
//this.value = ui.item.value;
return false;
},

select: function( event, ui ) {
var terms = split( this.value );
// remove the current input
terms.pop();
// add the selected item
terms.push( ui.item.value );
// add placeholder to get the comma-and-space at the end
terms.push( "" );
this.value = terms.join( ", " );
return false;
}

最佳答案

要使用自动建议选择多个值并使用 jquery UI 自动完成以逗号分隔选择,您必须对其进行大量更改。

您可以使用:MagicSuggest 干净的自动建议,可进行多项选择并用逗号分隔

演示:国家/地区选择自动建议

http://nicolasbize.com/magicsuggest/tutorial/3/

文档:

http://nicolasbize.com/magicsuggest/doc.html

关于javascript - 在焦点自动完成中选择多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21557929/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com