【问题标题】:Bootstrap modal in for loopfor循环中的引导模式
【发布时间】:2020-04-15 20:58:42
【问题描述】:

我正在使用 django 模板中的 for 循环遍历多模式,但模式仅适用于列表的第一个元素。我已经修改了<a href=...> 和<div class="modal fade"> 中的id 值,以按照Bootstrap modal, django for loop and model 和multi modals bootstrap in for loop django 中的建议随循环而变化。还是不行。

有什么建议吗? 这是我的代码的 sn-p:

{% for sess in session %}        
   <a href="#{{ sess.id }}" role="button" class="btn btn-fix text-left p-0" data-toggle="modal">Link</a>
   <div class="modal fade" id="{{ sess.id }}" role="dialog">
         <div class="modal-dialog modal-lg">
             <div class="modal-content">
                     <h5>{{sess.Title}}</h5>
                     <p class="text-right">
                       <button type="button" class="btn btn-outline-dark btn-sm" data-dismiss="modal">Close</button>
                     </p>
             </div>
         </div>
   </div> 
{% endfor %}

【问题讨论】:

    标签: bootstrap-4 django-templates bootstrap-modal


    【解决方案1】:

    我知道为什么:按钮和模式中的 id 值不应该是数字(所以不是{{sess.id}})。不过,它正在使用 test{{sess.id}}。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-19
      • 2014-03-31
      • 2019-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多