首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >引导下拉菜单不能在Rails中工作

问引导下拉菜单不能在Rails中工作
EN

Stack Overflow用户
提问于 2014-03-30 15:43:50
回答 1查看 773关注 0票数 0

我试图在我的Rails应用程序中实现下拉菜单。我复制了正确的代码以显示下拉菜单,但当我试图单击该菜单时,它并没有显示正确的选项。

使用引导cdn:

代码语言:javascript
复制
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Idealprospects</title>
  <%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" => true %>
  <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
  <%= csrf_meta_tags %>
</head>
<body>

index.html.erb

代码语言:javascript
复制
<div class="container">
<h1>Your Prospects</h1>
<table class="table table-striped table-bordered">
    <tr>
      <th class="center">Company</th>
      <th class="center">Name</th>
      <th class="center">Email</th>
      <th class="center">Telephone</th>
      <th class="center">Website</th>
      <th class="center">Action</th>
    </tr>

    <% @posts.each do |post| %>
      <tr>
        <td><%= post.company %></td>
        <td><%= post.contact %></td>
        <td><%= post.email %></td>
        <td><%= post.telephone %></td>
        <td><%= post.website %></td>
        <td>
            <div class="btn-group">
               <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
                Action <span class="caret"></span>
               </button>

            <ul class="dropdown-menu" role="menu">
              <li><%= link_to 'Show', post, class: "btn btn-link" %></li>
              <li><%= link_to 'Edit', edit_post_path(post), class: "btn btn-link" %>
              <li><%= link_to 'Destroy', post, method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-link" %> </li>
            </ul>
            </div>
        </td>
      </tr>
    <% end %>
</table>

<br>

<%= link_to 'New Post', new_post_path, class: "btn btn-link" %>

</div>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-30 15:47:50

从您的代码中,我看到您只包含了bootstrap.css,而它也需要js。

http://getbootstrap.com/components/#dropdowns

下拉

可切换的,上下文菜单,用于显示链接列表。与下拉JavaScript插件进行交互。

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

https://stackoverflow.com/questions/22746041

复制
相关文章

相似问题

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