私は、テージングとオートコンプリートにhttp://aehlke.github.io/tag-it/を使用しています。テジャングと条件付きオートコンプリート
コンソール:
GET .../source.php?term=value01
Javascriptを:
$("#input-newsearch-2").tagit({
singleField: true,
singleFieldDelimiter: ",",
allowSpaces: true,
autocomplete: ({
source: function(request, response) {
//var tagterm = $('#input-newsearch-2').val();
$.ajax({
url: "source.php",
dataType: "json",
data: {
//term: tagterm
//term: $('#input-newsearch-2').val()
term: request.term
},
//data: JSON.stringify({ term: $('#input-newsearch-2').val() }),
success: function(data) {
response(data);
}
});
console.log(request.term);
},
minLength: 3,
select: function(event,ui){
}
})
});
...値を入力するキー押すときタグ付けされます(警告($今のように、私は、単一の用語のために自動補完することができます( '#input-newsearch-2').val()= value01))次の語を検索することができます。
しかし、次の用語を入力するときに、オートコンプリートは毎回データベース全体を再度検索します。以前のタグを考慮してデータベースをフィルタリングしたいのですが?これはどのように可能ですか?
これは私のhtmlです:
<input id="input-newsearch-2" autocomplete="off" type="text">
// created by tagit
<ul class="tagit ui-widget ui-widget-content ui-corner-all">
<li class="tagit-choice ui-widget-content ui-state-default ui-corner-all tagit-choice-editable">
<li class="tagit-new">
<input class="ui-widget-content ui-autocomplete-input" autocomplete="off" type="text">
</li>
</ul>
...私は複数の値#入力-newsearch-2をタグ付けしましたときには、次のようになります。
$('#input-newsearch-2').val() = value01,value02,value03
@PhilippMこの答えは満たしていれば、そうでない場合は非常に適切ではない何かを説明するために私のコメントを残し、それをマークしてください私はそれに別の亀裂があります。この問題を解決のために動かし続けましょう。 – mickmackusa