我已经使用jQuery UI为多个值实现了自动完成。它工作得很好,但问题是我不想显式地从下拉列表中选择值(使用选项卡)。我的要求是,当我在下拉列表中导航时,我的搜索框应该被填充。然后我进入昏迷状态,再次从下拉列表中继续搜索。
我基本上尝试了jqueryUI自动完成中的代码片段,但焦点被抑制了。我想要的是,我们应该能够使用焦点选择它,然后给它一个逗号,然后继续搜索,而不是选择选项卡上的项目。
.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;
}发布于 2017-04-04 12:45:53
要使用自动建议选择多个值,并使用jquery UI自动完成功能使用逗号分隔选择,您必须对其进行大量更改。
相反,您可以使用: MagicSuggest clean auto suggest进行多项选择,并用逗号分隔
演示:国家/地区选择自动建议
文档:
发布于 2014-02-05 00:39:09
你有没有试过用JQuery autocomplete代替TextExt?它看起来更适合你的需求:http://textextjs.com/manual/examples/filter-with-suggestions.html
https://stackoverflow.com/questions/21557929
复制相似问题