简体   繁体   English

如何使用laravel在每个id的bootstrap模式中获取动态数据?

[英]How to get dynamic data in bootstrap modal for each id by using laravel?

I am developing an app which requires to show the data at every click on my different list of icon.我正在开发一个应用程序,它需要在每次点击我的不同图标列表时显示数据。 The problem is how to display data in to bootstrap modal according to id.问题是如何根据 id 将数据显示到 bootstrap modal。 Thanks in advance.提前致谢。 index.blade.php . index.blade.php 。

<div class="col-md-3">
     <button  type="button" class="btn btn-success " data-toggle="modal" data-target="#myModal" data-id="{{$post->id}}">Ajouter
  </button>
 </div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="modelTitleId"
  aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
            <div class="modal-content" >
                <div class="modal-header">
                    <h5 class="modal-title">Modal title</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body" >
                    <div class="container-fluid">
                          <div class="row">
                              <div class="col-md-12 ">
                                 <div class="panel panel-default">
                                    <div class="panel-heading text-center">Nouvelle annonce</div>
                                         <div class=" form-group col-sm-6">
                                            <img class="cart-img img-responsive" src="images/cover_image/{{$post->cover_image}}" alt="IMG-PRODUCT">
                                         </div>
                                        <div class=" form-group col-sm-3">
                                             <span id="layer_cart_product_title" class="product-name layer_cart_product_title"><h2> {{$post->nom_comr}}</h2> </span>
                                                <hr>
                                            <span id="layer_cart_product_ti" class="product-name"><h4> &nbsp;{{$post->date_perm}}</h4> </span>
                                            <span id="layer_cart_product_ti" class="product-name"><h4> &nbsp;{{$post->offre}}</h4> </span>
                                                    <hr>
                                             <span id="layer_cart_product_ti" class="product-name"><h4> &nbsp;{{$post->pv_ht}}</h4> </span>
                                            </div>
                                            
<button  type="button" class="btn btn-success " data-toggle="modal" data-target="#myModal{{$post->id}}" data-id="{{$post->id}}">Ajouter</button>
<div class="modal fade" id="myModal{{$post->id}}" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true">

thats work for me那对我有用

I solve my problem by passing the post id in data-target and also in midel in我通过在 data-target 和 midel 中传递帖子 ID 来解决我的问题

    <button  type="button" class="btn btn-success " data-toggle="modal" data-target="#{{$post->id}}">Ajouter </button>

<div class="modal fade" id="{{$post->id}}" tabindex="-1" role="dialog" aria-labelledby="modelTitleId" aria-hidden="true">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM