【发布时间】:2017-07-29 19:26:48
【问题描述】:
我目前正在尝试在 Laravel 5.3 中进行多次删除。我想成为像使用复选框删除电子邮件一样的东西。
但在删除之前,我想使用模态进行确认。
我的刀片中的表格看起来像这样
<form id="linkForm" action="/links/deleteLinks" method="POST">
{{ csrf_field() }}
{{ method_field('POST') }}
<div class="ibox-content">
<div class="table-responsive">
<table class="table table-striped table-bordered table-hover dataTables-example footable toggle-arrow-tiny">
<div class="btn-group btn-group-sm pull-right">
<a data-toggle="modal" class="btn btn-primary" href="#modal-form-add" data-dismiss="modal"><i class="fa fa-plus-square-o"></i> Add</a>
<input class="btn btn-danger" type="submit" value="Delete">
</div>
<thead>
<tr>
<th></th>
<th data-toggle="true" data-hide="all">Company</th>
{{-- <th>Category</th> --}}
<th>Page Url</th>
<th data-hide="all">Domain Url</th>
<th>Destination Url</th>
<th>Contact Email</th>
<th data-hide="all">Trust Flow</th>
<th data-hide="all">Estimated Traffic</th>
<th data-hide="all">Domain Authority</th>
<th>Status</th>
<th>Note</th>
<th data-hide="all">Live</th>
<th>Action</th>
{{-- <th>Delete</th> --}}
</tr>
</thead>
<tbody>
@foreach($links as $link)
<tr>
<td align="center"><input type="checkbox" class="i-checks" id="input" name="input[]" value="{{ $link->page_url }}"></td>
<td>{{ $link->company->name }}</td>
{{-- <td>{{ $link->category_id }}</td> --}}
<td>{{ $link->page_url }}</td>
<td>{{ $link->domain_url }}</td>
<td>{{ $link->destination_url }}</td>
<td>{{ $link->contact_email }}</td>
<td>{{ $link->trust_flow}}</td>
<td>{{ $link->estimated_traffic }}</td>
<td>{{ $link->domain_authority }}</td>
<td>{{ $link->status }}</td>
<td>{{ $link->comment }}</td>
<td>
@if($link->is_live)
{{ 'Live' }}
@else
{{ 'Down' }}
@endif
</td>
<td>
<a data-toggle="modal" href="#modal-form-{{ $link->id }}" data-dismiss="modal"><i class="fa fa-pencil"></i> Edit</a>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</form>
modal.blade.php
<div id="myModal" class="modal inmodal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-body text-center">
<i class="fa fa-exclamation-triangle modal-icon"></i>
<h2><strong>Are you sure?</strong></h2>
{{-- <p class="text-muted">Are you sure you want to delete the following link(s)?</p> --}}
<p id="checkid"></p>
<div class="row">
<button id="cancelDelete" type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button class="btn-primary btn" id="SubForm">Confirm and Submit The Form</button>
</div>
</div>
</div>
</div>
javascript
$("#linkForm").validate({
submitHandler: function (form) {
$("#myModal").modal('show');
$('#SubForm').click(function () {
form.submit();
});
}
});
如何在不为多次删除创建另一个函数和路由的情况下将我的数组提交给控制器,而只使用 links.destroy?
【问题讨论】:
标签: laravel laravel-5.3