我在我的项目中使用了引导标签输入。现在,我想在标签输入中实现类型化建议,我已经实现了它,但是它不起作用。在这里,我添加我的代码。有什么帮助吗?先感谢您。
<div class="category-container">
<input type="text" id="category" data-role="tagsinput"/>
</div>
var data = ["Amsterdam",
"London",
"Paris",
"Washington",
"New York",
"New Jersey",
];
var citynames = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: $.map(data, function (city) {
return {
name: city
};
})
});
citynames.initialize();
$('#category').tagsinput({
typeaheadjs: [{
minLength: 1,
highlight: true,
},{
minlength: 1,
name: 'citynames',
displayKey: 'name',
valueKey: 'name',
source: citynames.ttAdapter()
}],
freeInput: true
});