我正在开发一个应用程序,它需要在每次点击我的不同图标列表时显示数据。问题是如何根据 id 在 bootstrap modal 中显示数据。提前致谢。索引.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">×</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>
2 回答
不负相思意
TA贡献1777条经验 获得超10个赞
<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">
那对我有用
qq_遁去的一_1
TA贡献1725条经验 获得超7个赞
我通过在 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">
添加回答
举报
0/150
提交
取消