こんにちは私は、データベース上で検索を行い、ユーザーがtypeaheadを使用して入力しているときに自動募集を提供しようとしています。ユーザーが入力するとデータが返されますが、自動入力は入力フィールドの下に表示されません。Twitter Typeaheadが提案を表示しない
$(window).load(function(){
// Instantiate the Bloodhound suggestion engine
var employees = new Bloodhound({
datumTokenizer: function (datum) {
return Bloodhound.tokenizers.whitespace(datum.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: 'https://www.example.com/prs/emp.php?query=%QUERY',
wildcard: '%QUERY',
filter: function (employees) {
return $.map(employees.results, function (employee) {
return {
label: employee.label,
value: employee.value
};
});
}
}
});
// Initialize the Bloodhound suggestion engine
employees.initialize();
// Instantiate the Typeahead UI
$('.typeahead').typeahead(null, {
displayKey: 'value',
source: employees.ttAdapter(),
templates: {
suggestion: function(data){
return '<p>Name: <strong>' + employee.label + '</strong> | ID: ' + employee.value + '</p>';}
}
});
<input type="text" autocomplete="off" spellcheck="false" class="typeahead employeeName form-control" name="employeeName" style="margin:0px auto;overflow:visible;" id="employeeName" placeholder="Employee Name">
私はそれがデータを表示しません、なぜわからないのphpファイルから [{"label":"Austin, Pickering","value":"155"}]
を次の応答を取得しています。私はそれを理解しようと時間を費やしました。これについてのどんな助けも大いに感謝されるでしょう。 エラー:{ 「メッセージ」:「キャッチされないでSyntaxError:入力の予期しない終わり」、 「ファイル名」:私はスニペットにコードを実行した
こんにちは感謝を完成させます。コードスニペットは、ここではもちろん、私はサンプルURLにURLを変更したデータベースへのリモートクエリのbecaueで実行されません。 – AKAust