【发布时间】:2020-11-18 20:44:14
【问题描述】:
我想制作一个表格,每行都有一个编辑按钮。编辑按钮将呈现一个带有已加载数据的模式弹出窗口。
这是我的blade.php
<div class="card-body">
@foreach($employee_education as $employee_education)
<div class="card card-primary card-outline">
<div class="card-header bg-white">
<h5 class="card-title m-0">
{{ $employee_education->degree_title }}
</h5>
<a
href="#"
data-toggle="modal"
id="education_edit_link"
data-target="#education_edit_modal"
class="btn btn-primary btn-xs"
style="float:right;color:white!important;"
>
<i class="fas fa-edit"></i> Edit
</a>
</div>
<div class="card-body bg-light">
<table class="table table-hover table-sm table-borderless">
<tbody>
<tr>
<th>Degree Title</th>
<td>{{$employee_education->degree_title}} </td>
</tr>
<tr>
<th>Institute</th>
<td>{{$employee_education->institute}} </td>
</tr>
<tr>
<th>Address </th>
<td>{{$employee_education->address}} </td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- Modal -->
<div
class="modal fade"
id="education_edit_modal"
tabindex="-1"
role="dialog"
aria-labelledby="connection_detailsLabel"
aria-hidden="true"
>
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-body">
<div class="card-body">
<table class="table table-hover table-sm table-borderless">
<tbody>
<tr>
<th>Degree Title</th>
<td>{{$employee_education->degree_title}} </td>
</tr>
<tr>
<th>Institute</th>
<td>{{$employee_education->institute}} </td>
</tr>
<tr>
<th>Address </th>
<td>{{$employee_education->address}} </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" type="submit" id="btn_update" class="btn btn-primary">Send</button>
</div>
</div>
</div>
</div>
<!-- Modal End -->
@endforeach
但模态每次只显示第一行数据。如何获取在我的模态中加载的单击行数据的数据
【问题讨论】:
-
不要在循环中使用相同的
id属性。ids 在文档中必须是唯一的
标签: javascript jquery laravel laravel-blade