使用rails link_to和bootstrap modal打开新页面

时间:2013-06-04 18:20:10

标签: ruby-on-rails twitter-bootstrap modal-dialog

我在使用Rails上的bootstrap在模式中加载新页面时遇到了一些问题。

以下是我的eventos / index.html.erb

的重要部分
<div id="content">        
  <% @eventos.each do |evento| %>
  <!--Bar 2-->
  <div class="mosaic-block bar2">
  **<%= link_to(evento, :class=>"mosaic-overlay", :id => "evento" , "data-toggle" =>     "modal", 'data-target' => '#eventoModal') do %>**
    <div class="details">
      <h4><%= evento.local %> - <%= evento.data.to_time.strftime('%e/%m') %></h4>
      <h4>Mais+</h4>
    </div>
    <%end%>
  <div class="mosaic-backdrop"><%= image_tag evento.attachment.url(:small) %></div>
  </div>
 <% end %>

正如你所看到的,我的“evento”有一个link_to(渲染的html:

a href="/eventos/1" class="mosaic-overlay" data-target="#eventoModal" data-toggle="modal" id="evento"

但是当我点击链接时,没有任何反应(在添加它工作的模态之前)

这是evento / show.html.erb

<div class="modal" id="eventoModal">
     <p>Some code</p>
</div>

最后在我的资产/ javascripts / eventos.js.coffe我有这个:

$('#eventoModal').modal(options)

任何人都可以帮我在evento / index.html.erb页面的模板中显示evento / show.html.erb吗?

1 个答案:

答案 0 :(得分:0)

我认为你的jQuery选择器是错误的

$('#eventoModal').modal(options)

应该是

$('#evento').modal(options)