Reveal Modal 揭示了循环迭代中的最后一个值 Foundation-zurb 问题 [英] Reveal Modal is revealing last value in loop iteration Foundation-zurb issue

查看:28
本文介绍了Reveal Modal 揭示了循环迭代中的最后一个值 Foundation-zurb 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 rails project_site 中使用 .each 在 index#action 中,每行显示基础模型,但是

问题是模型显示只显示每个模型显示中最后一个 project_site 的 id.我想显示应该显示当前 project_site 的 ID.

<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site|%><tr><td><%= project_site.user.name %></td><td><div class="完整展示";id=exampleModal1"数据显示><%= project_site.id %><button class="close-button";data-close aria-label =关闭模式";类型=按钮"><span aria-hidden="true">&times;</span>

<p><button class="button small warning button-margin-top fi-eye";数据打开=exampleModal1">查看</button></p></td></tr><%结束%>

解决方案

每个模态都有相同的 id,所以最后一个总是获胜.更改视图,使每一行的模态都有自己的 id,打开按钮调用正确的...

<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site|%><tr><td><%= project_site.user.name %></td><td><% site_modal_id = "site_modal_#{project_site.id}";%><div class="完整展示";id="<%=site_modal_id%>"数据显示><%= project_site.id %><button class="close-button";data-close aria-label =关闭模式";类型=按钮"><span aria-hidden="true">&times;</span>

<p><button class="button small warning button-margin-top fi-eye";data-open="<%=site_modal_id%>">查看</button></p></td></tr><%结束%>

请注意,如果您有很多项目站点,您的页面会变慢,最好有一个单一的模式,您可以在其中传递数据.

i am using .each in rails project_site in index#action with foundation model reveal on each row but

issue is model reveal just shows id of last project_site in each model-reveal. i want reveal should reveal id of current project_site.

<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site| %>
  <tr>
      <td><%= project_site.user.name %></td>

       <td>

          <div class="full reveal" id="exampleModal1" data-reveal>
              <%= project_site.id %>
              <button class="close-button" data-close aria-label="Close modal" type="button">
                <span aria-hidden="true">&times;</span>
              </button>
           </div>

            <p><button class="button small warning button-margin-top fi-eye" data-open="exampleModal1"> View</button></p>


        </td>
  </tr>

<% end %>

解决方案

Each modal has the same id, so the last one always wins. Change the view so each row's modal has its own id, and the open button calls the proper one...

<% @project.project_sites.where(submission_status: true).order("created_at desc").each do |project_site| %>
  <tr>
      <td><%= project_site.user.name %></td>

       <td>
          <% site_modal_id = "site_modal_#{project_site.id}" %>
          <div class="full reveal" id="<%= site_modal_id %>" data-reveal>
              <%= project_site.id %>
              <button class="close-button" data-close aria-label="Close modal" type="button">
                <span aria-hidden="true">&times;</span>
              </button>
           </div>

            <p><button class="button small warning button-margin-top fi-eye" data-open="<%= site_modal_id %>"> View</button></p>


        </td>
  </tr>

<% end %>

Note that if you have a lot of project sites your page is going to slow down and it would be better to have a single modal where you pass in the data on the cick.

这篇关于Reveal Modal 揭示了循环迭代中的最后一个值 Foundation-zurb 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆