简体   繁体   English

Rails 4 Bootstrap-下拉菜单

[英]Rails 4 Bootstrap - dropdown menu

I have a rails 4 app with bootstrap. 我有一个带有Bootstrap的Rails 4应用程序。

I have required bootstrap in my application.js file. 我的application.js文件中需要引导程序。

I am trying to produce a series of drop down menus that have a tile question, a caret and an answer which is selected from a drop down menu. 我正在尝试生成一系列下拉菜单,这些菜单有一个平铺问题,一个插入符号和一个从下拉菜单中选择的答案。

I'm afraid nothing that I've tried to implement this has worked at all. 恐怕我尝试实现的任何方法都没有奏效。

Please could some one give me steps (and examples) of how to implement this. 请有人给我一些步骤(和示例),以了解如何执行此操作。 By way of example, my hope is to have a series of fields that follow this format: 举例来说,我希望有一系列遵循这种格式的字段:

<div class="row">
    <div class="col-md-8">

<div class="btn-group">
    <button class="btn">I am a:</button>
    <button class="btn dropdown-toggle" data-toggle="dropdown">
    <span class="caret"></span>
   </button>
 <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu">
   <li><a tabindex="-1" href="#">Student</a></li>
   <li><a tabindex="-1" href="#">Academic</a></li>
   <li><a tabindex="-1" href="#">SME</a></li>
   <li><a tabindex="-1" href="#">Corporate</a></li>
   <li><a tabindex="-1" href="#">Grantor</a></li>
   <li><a tabindex="-1" href="#">Investor</a></li>
   </ul>
</div>

If you choose Student from the list, then a label next to the question and caret should read student. 如果从列表中选择“学生”,则问题和插入符号旁边的标签应显示为“学生”。

I have tried both options on the bootstrap javascript drop down page. 我尝试了引导javascript下拉页面上的两个选项。 Neither has worked. 两者都没有起作用。 I am not sure why I have tab index in the list items. 我不确定为什么列表项中有选项卡索引。 I copied that from one of the answers on this forum in relation to a similar question. 我复制了该论坛上与类似问题相关的答案之一。

Please help if you know how. 如果您知道如何请帮助。 Thanks very much. 非常感谢。

add bootstrap to your gemfile 将引导程序添加到您的gemfile

add //= require bootstrap in your application.js 在application.js中添加//= require bootstrap

add @import "bootstrap"; 添加@import "bootstrap"; in your application.css.scss 在您的application.css.scss中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM