我有多个字段需要BS2中的新Typeahead功能。与其在表单上的每个字段重复数据,不如将其合并到一个位置(可能是JS文件)中。我只是不确定确切的语法。
这是我的其中一个领域所拥有的:<input data-provide="typeahead" data-items="6" data-source='["4","4.5","5","5.5","6","6.5","7","7.5","8","8.5","9","9.5","10","10.5","11","11.5","12","12.5","13","13.5","14","14.5","15","15.5","16","16.5","17","17.5","18","18.5","19","19.5","W5","W5.5","W6","W6.5","W7","W7.5","W8","W8.5","W9","W9.5","W10","W10.5","W11","W11.5","W12","W12.5","W13","W13.5","W14","1Y","1.5Y","2Y","2.5Y","3Y","3.5Y","4Y","4.5Y","5Y","5.5Y","6Y","6.5Y","7Y","1C","1.5C","2C","2.5C","3C","3.5C","4C","4.5C","5C","5.5C","6C","6.5C","7C","7.5C","8C","8.5C","9C","9.5C","10C","10.5C","11C","11.5C","12C","12.5C","13C","13.5C","OS","N/A"]' name="size1" type="text" class="span1" autocomplete="off">
最佳答案
Bootstrap中的typeahead功能实际上只是jQuery UI的autocomplete
功能
跳过data-provide
属性,然后自行初始化字段。你应该可以说
$('.typeahead').typeahead({
source: [ ... your array ... ]
});
这就是Bootstrap's own docs的意思,它与jQuery UI's docs for Autocomplete匹配
关于php - 在Twiiter Bootstrap v2中整合Typeahead/JSON数据源?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9369373/