我插入了一个测试切换按钮(从演示粘贴)
#menu1.dropdown
%a.dropdown-toggle{:'data-toggle' => "dropdown", :href => "#menu1"}
Options
%b.caret
%ul.dropdown-menu
%li
= link_to "Action", "#"
%li
= link_to "Another action", "#"
%li
= link_to "Something else here", "#"
%li.divider
%li
= link_to "Separated link", "#"
显示按钮,但所有选项都可见,根本没有切换
button-toggle.js 插件存在(签入资产),我已经添加到我的应用程序 js 文件中
$(document).ready ->
$('.dropdown-toggle').dropdown()
这很奇怪,因为在我的页面顶部,在导航栏中,我已经有一个下拉按钮来选择网站语言......而且这个工作正常......(同时显示语言和标志)
.btn-group{:style => "margin-top: 4px; float:right;"}
%a.btn{:'data-toggle' => "dropdown", :href => "#", :id => "babLocaleSelect"}
%span.babFlag{:class => "babFlag-#{I18n.locale}"}= I18n.locale.to_s
= I18n.t(I18n.locale)
%a.btn.dropdown-toggle{:'data-toggle' => "dropdown", :href => "#"}
%span.caret
%ul.dropdown-menu.bablevel-content
- other_backoffice_languages.each do |language|
%li.babLocale
%a{:href => backoffice_language_path(:locale => language), :id => "#{language}_language_link" }
%span.babFlag{:class => "babFlag-#{language}"}= I18n.t(language)
= I18n.t(language.to_sym)
我也尝试调试,插入
$(".dropdown-menu").click (event) ->
alert 'dd clicked'
这是由两个菜单触发的,所以它已安装,但第二个是打开的,从不切换