微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Laravel 中的动态 Bootstrap 模态

如何解决Laravel 中的动态 Bootstrap 模态

我想在 Bootstrap Modal 中动态显示产品详细信息。 这是我的控制器

$products = Product::all();
return view('landing')->with('products',$products);

我的观点

@foreach($products as $index => $product)
 <div class="product-text col-lg-6">
  <h3><a href="#">{{$product->name}}</a></h3>
   <div class="product-Meta">
    <p>{{$product->details}}</p>
   </div>
   <a data-toggle="modal" data-target="{{ $index }}">Modal</a>
  </div>
@endforeach
      
    <div class="modal fade" id="{{ $index }}" role="dialog">
        <div class="modal-dialog modal-dialog-centered modal-lg">
        
        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header">
            <h4 class="modal-title">{{$product->name}}</h4>
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            
            </div>
            <div class="modal-body">
            <p>{{$product->description}}</p>
            </div>
            <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            </div>
        </div>
        
        </div>
    </div>

如何显示特定产品的详细信息?

解决方法

我们可以使用两种方法来解决这个问题。

  1. 使用 text = 'Overview At Emburse our mission is to help make our users’ lives — and their businesses – better.We are dramatically transforming how organizations manage corporate expenses and invoices. We humanize work by automating manual tasks and saving users’ time,so they can focus on what matters most — their family,community,or more rewarding work.We help CFO’s give their employees a simple and amazing experience while ensuring.compliance and reducing costs. Our solutions are tailored for companies from start-ups to enterprises. We have more than 14,000 clients and 4.5 million users globally. Embue ' print(len(text)) parser = GingerIt() result=parser.parse(text) print(result) 包含模型代码。 实际上,这不是一个好方法。加载页面需要更多时间,这不是一个好习惯

  2. 使用 foreach。这是通过单击按钮在模型上显示您的产品详细信息的最佳方式

所以你可以使用第二种方式。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?