简体   繁体   English

如何在Rails上的ruby中使用带有link_to的模式

[英]how to use a modal with link_to in ruby on rails

I am trying to link_to a button action 我正在尝试link_to一个按钮动作

 <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newTag">
          <i class="fa fa-plus"></i> New Tag
        </button>

i want to pass it as a path: to this code: 我想将其作为path:传递给此代码:

<%= render "shared/empty_view", path: contacts_path, title: "You do not have any tags!", action:"Create Tag", image: "/no_products.png" %>

I have tried following similar answers for similar questions, but i cant seem to get the right syntax. 我已经尝试按照类似的答案回答类似的问题,但是我似乎无法获得正确的语法。

<%= link_to "#newTag", data: { toggle: "modal" } do %>
  <i class="fa fa-plus"></i> New Tag
<% end %>

<div id="newTag" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <p>Some text in the modal.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

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

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