【发布时间】:2014-04-03 23:52:34
【问题描述】:
我正在尝试将Bootstrap 3 Typeahead plugin(如果我理解正确的话,基本上是在 Bootstrap 3 中删除之前的旧 Bootstrap 预输入功能的一个端口)与Bootstrap-Tagsinput plugin 集成。
让这些单独工作没有问题,包括 JSON 预取 typeahead 功能。我不明白如何将两者结合起来。我不认为这应该太难,但我对 Javascript 的知识显然缺乏。
这是我的输入字段:
<input type="text" id="tagFilter" data-provide="typeahead" data-role="tagsinput">
这是在 Javascript 中调用 typeahead 插件的方式:
//The typeahead
$.get('tags.php', function(data){
$("#tagFilter").typeahead({ source:data });
},'json');
如果有帮助,Tagsinput 在其文档中有一个示例解释如何实现 twitter typeahead.js:
$('input').tagsinput();
// Adding custom typeahead support using http://twitter.github.io/typeahead.js
$('input').tagsinput('input').typeahead({
prefetch: 'citynames.json'
}).bind('typeahead:selected', $.proxy(function (obj, datum) {
this.tagsinput('add', datum.value);
this.tagsinput('input').typeahead('setQuery', '');
}, $('input')));
但我使用的是不同的插件。我发现那个在我头上。
再次感谢。
【问题讨论】:
标签: javascript jquery twitter-bootstrap bootstrap-typeahead bootstrap-tags-input