使jQuery UI自动完成处理多个单词的最简单方法是什么?截至目前,空格将终止自动完成。
$.ajax({
type: "GET",
cache: false,
dataType: 'json',
url: "http://localhost/some_json",
success:
function(response) {
$("#title").autocomplete({
source: response,
minLength: 2,
select: function (event, ui) {
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
//
}
}
});
答案 0 :(得分:1)
我设置了这个基本的例子:
<label for="tags">Tags: </label> <input id="tags">
var availableTags = ["Action alpha", "Action omega", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme"];
$("#tags").autocomplete({
source: availableTags
});
对我来说,空间完成后自动完成。尝试挖掘Action a
,您将在输入
答案 1 :(得分:-1)
$("#tagnames").autocomplete("/tags/filter",
{
max: 6,
highlightItem: true,
multiple: true,
multipleSeparator: " ",
})
要为多个字词启用自动填充,您应设置选项multiple
:true
和multipleSeparator
:" "