首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用bootstrap-sass扩展bootstrap typeahead

使用bootstrap-sass扩展bootstrap typeahead
EN

Stack Overflow用户
提问于 2012-08-18 10:05:17
回答 1查看 1K关注 0票数 0

我正在使用bootstrap-sass gem创建一个rails站点,它工作得很好。我还成功地在我的js.erb上初始化了typeahead:

代码语言:javascript
复制
$container.find('.typeahead').typeahead({source: [<%= @cities %>], items:20});

但现在我想使用typeahead的扩展版本,它使用kvp对象数组而不是字符串。来自tcrosen的This one看起来还不错。

我将他们的bootstrap-typeahead.js添加到app/assests/javascripts文件夹中。更改application.js以包含该文件:

代码语言:javascript
复制
...
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-typeahead
//= require_tree .

但看起来他使用的是bootstrap.min.js上定义的typeahead函数,而不是新的。

我怎样才能让他使用正确的文件呢?

ps:我正在使用其他的bootstrap javascripts插件,所以我不能删除bootstrap.min.js

EN

回答 1

Stack Overflow用户

发布于 2012-08-27 05:20:58

而不是指定全局文件

代码语言:javascript
复制
//= require bootstrap

您可以单独要求它们:

代码语言:javascript
复制
//= 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测试。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12015243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档