【发布时间】:2016-07-21 02:12:32
【问题描述】:
我的小提琴是here。
我正在基于this answer 扩展the Fiddle here 中的示例以使用Bloodhound。
我正在使用以下 sn-p 预取数据:
prefetch_url='https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/assets/cities.json';
var cities = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('text'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch: prefetch_url,
ttl:1
});
cities.initialize();
这是基于示例here。
我已经修改了tagsinput() 中的typeahead,以适当地获取和使用text 和值字段。
我有以下问题:
- 文本框的大小不断变化。
- 如果我在文本框中输入内容,我会收到来自
bloodhound.js文件的Uncaught TypeError: sync is not a function。
我希望根据cities.json 填充文本框。因此,如果我输入 Amsterdam 和 Washington,我应该会看到 $("#myBox").val() = "1,4"。
我认为我可能错误地混合了不同版本的预输入,但我尝试了几种 JS 文件组合,但没有任何运气。
【问题讨论】:
-
如果我在 Safari 或 Chrome 上运行你的小提琴,则没有
Uncaught TypeError。重现此问题的步骤是什么?你能解释一下textbox keeps changing是什么意思吗?你想让文本框固定宽度吗? -
谢谢,@gearsdigital。是的,我希望它是固定宽度。出于某种原因,我不再像您所说的那样收到 TypeError,但文本框中没有填充
cities。
标签: twitter-bootstrap bootstrap-typeahead bloodhound bootstrap-tags-input