0
我有我用foreach分發的數據列表。我想用bootstrap模態獲得每個數據的細節。如何獲得laravel上的Bootstrap模式數據5
這是我的代碼
<div class="container bg-white" style="padding: 20px;">
@foreach ($hadiah as $h)
<div class="col-md-6 rewards" >
<div class="rewards-box">
<div class="img">
<img class="imagePreview" src="https://admin.philipscontractorclub.com/uploads/rewards/{{$h->image}}">
</div>
<div class="caption">
<h3 class="title">{{$h->title}}</h3>
<p class="point_needed"><span class="fa fa-certificate"></span> {{$h->point_needed}}</p>
<p class="description">{{$h->description}}</p>
<button type="button" class="btn btn-info btn-lg detail-item" data-id="{{ $h->id }}" data-toggle="modal" data-target="#myModal">Buka</button>
</div>
</div>
</div>
@endforeach
</div>
這是我的模態
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<div class='row'>
<center>
<div class='col-md-12'>
<img class="modal-image">
</div>
</center>
<div class='col-md-12'>
<p align='center' class="modal-poin"><b>Poin dibutuhkan</b></p>
</div>
<div class='col-md-12'>
<p align='justify' class="modal-desc">Deskripsi</p>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
這是我的javascript
<script type="text/javascript">
$("body").on("click",".detail-item",function(){
var id = $(this).data('id');
var nama = $(this).find('title').text();
var src = $(this).find('.imagePreview').attr('src');
var poin = $(this).find('point_needed').text();
var desc = $(this).find('description').text();
$("#myModal").find(".modal-title").text(nama);
$("#myModal").find('.modal-image').attr('src', src);
$("#myModal").find(".modal-poin").text(poin);
$("#myModal").find(".modal-desc").text(desc);
});
</script>
結果是零中。我想每一個數據的細節,如果我按一下按鈕
感謝您的幫助
謝謝,那個工作。我忘了輸入'。'在find('title')。text() –