我正在使用bootstrap-sass gem创建一个rails站点,它工作得很好。我还成功地在我的js.erb上初始化了typeahead:
$container.find('.typeahead').typeahead({source: [<%= @cities %>], items:20});但现在我想使用typeahead的扩展版本,它使用kvp对象数组而不是字符串。来自tcrosen的This one看起来还不错。
我将他们的bootstrap-typeahead.js添加到app/assests/javascripts文件夹中。更改application.js以包含该文件:
...
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-typeahead
//= require_tree .但看起来他使用的是bootstrap.min.js上定义的typeahead函数,而不是新的。
我怎样才能让他使用正确的文件呢?
ps:我正在使用其他的bootstrap javascripts插件,所以我不能删除bootstrap.min.js
发布于 2012-08-27 05:20:58
而不是指定全局文件
//= require bootstrap您可以单独要求它们:
//= require bootstrap-affix
//= require bootstrap-alert
//= require bootstrap-button
//= require bootstrap-carousel
//= require bootstrap-collapse
//= require bootstrap-dropdown
//= require bootstrap-modal
//= require bootstrap-scrollspy
//= require bootstrap-tab
//= require bootstrap-tooltip
//= require bootstrap-transition所以不要包括最后一个//= require bootstrap-typeahead。这样,您就可以从tcrosen请求bootstrap-typeahead javascript文件(将其放入您的资产javascript目录中并需要它,但不要忘记将其重命名,否则将使用旧的bootstrap typeahead )。使用bootstrap-sass和tcrosen/twitter-bootstrap-typeahead测试。
https://stackoverflow.com/questions/12015243
复制相似问题