我将动态变量传递给模式部分时遇到问题。 每次我从表中获得第一行时,引导程序的模式便无法正常工作。我使用Laravel框架。
如何将动态变量传递给部分? 有人可以帮我吗?
这是我的代码:
showCustomer.blade.php
<div class="row">
<div class="col-12">
<table id="myTable" class="table table-hover display" cellspacing="0" width="100%">
<thead class="thead-light">
<tr>
<th class="th-sm">ID</th>
<th class="th-sm">Name</th>
<th class="th-sm">Surname</th>
@if($perm === true)
<th class="no-sort"></th>
@endif
</tr>
</thead>
<tbody>
@foreach($customers as $customer)
<tr>
<td>{{$customer->id}}</td>
<td class="font-weight-bold">{{$customer->name}}</td>
<td>{{$customer->surname}}</td>
@if($perm === true)
<td class="text-right">
<div class="btn-group" role="group">
<!-- Button trigger delete modal -->
<button type="button" class="btn btn-danger" data-toggle="modal"
data-target="#deleteModal{{$customer->id}}"><i class="far fa-trash-alt"></i></button>
<!-- Delete button -->
@section('deleteModalAction')
<a href="{{ route('backstage.removeCustomer',$customer->id) }}" class="btn btn-primary"
role="button">Yes</a>
@endsection('deleteModalAction')
@include('components.deleteModal')
<!-- Edit button -->
<a href="{{ route('backstage.showCustomerForm',$customer->id) }}">
<button type="button" class="btn btn-default">
<i class="far fa-edit"></i></button> </a>
</div>
</td>
@endif
</tr>
@endforeach
</tbody>
</table>
</div>
removeModal.blade.php
<div class="modal fade" id="deleteModal{{$customer->id}}" tabindex="-1" role="dialog" aria-labelledby="deleteModal"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="deleteModal">Confirm</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p class="text-center">Are you sure?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-light" data-dismiss="modal">Cancel</button>
@yield('deleteModalAction')
</div>
</div>
</div>
每一次,“ deleteModalSection”部分都具有相同的变量(动态表的第一个ID)...
我尝试了很多方法,但无济于事。
通常,引导模态对于其余视图是通用的。
谢谢。