0

I have a Rails view with two icons. Each icon should open a different modal (using a partial).

The issue is that both icons are opening the same modal (the first one).

Here is the code to display the modals:

<a data-toggle="modal" href="#workorder-<%= workorder.id %>">
  <i class="icon-list"></i><%= workorder.wologs.count %>
  <%= render :partial => "wologs/history", locals: {workorder: workorder} %>
</a>
<a data-toggle="modal" href="#workorder-<%= workorder.id %>">
  <i class="icon-ok-sign"></i><%= workorder.tasks.count %></a>
  <%= render :partial => "tasks/taskslist", locals: {workorder: workorder} %>
</a>

Thanks for the help!

4

1 回答 1

1

正如 MrYoshiji 已经提到的原因是两个链接指向相同的 id,所以启动了相同的模式。

我想补充一点,如果部分是模态体,将模态体放在链接内也是不正确的。

根据引导示例:

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>

<!-- Modal -->
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
</div>

链接和模态是两个完全不同的 div。

所以解决方法是:

在不同的 div 中启动 partial 并为它们分配不同的 id。

于 2013-08-26T15:58:35.120 回答