我試圖創建一個使用sweetalert在我的應用程序刪除確認,這裏是我迄今所做..使用sweetalert刪除確認?
查看:
<div class="box-button">
{!! Form::open(['method' => 'POST', 'class' => 'deleteedition', 'action' => ['[email protected]', $edition->id]]) !!}
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
{!! Form::submit('Delete', ['class' => 'btn btn-danger btn-sm', 'id'=>'deleteedition1']) !!}
{!! Form::close() !!}
</div>
JS:
<script>
$("#deleteedition1").on("click", function() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this lorem ipsum!", type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
closeOnConfirm: false
},
function() {
$(".deleteedition").submit();
});
});
</script>
的問題是當我點擊刪除按鈕時,它會繼續刪除文件,甚至認爲我還沒有確認它。有人能告訴我我做錯了什麼嗎?謝謝您的幫助!
全表視圖:
<table class="table table-borderless table-responsive" style="table-layout: fixed;">
<thead>
<tr>
<th style="overflow: hidden;"></th>
@if (Auth::check() && Auth::user()->level == 'admin')
<th style="width: 130px;"></th>
@endif
</tr>
</thead>
<tbody>
<?php foreach ($edition_list as $edition): ?>
<tr>
<td style="overflow: hidden;"><a href="{{ url('edition/' . $edition->id) }}">Volume {{ $edition->volume }}, Nomor {{ $edition->number }} ({{ Carbon\Carbon::parse($edition->start)->format('F, Y') }})</a>
@if (Auth::check() && Auth::user()->status == '1')
@if (Carbon\Carbon::now()->between(Carbon\Carbon::parse($edition->start), Carbon\Carbon::parse($edition->limit)))
<p style="font-size: 10px; color: red;">Edisi aktif periode : {{ Carbon\Carbon::parse($edition->start)->format('j F Y') }} sampai {{ Carbon\Carbon::parse($edition->limit)->format('j F Y') }}</p>
@else
<p></p>
@endif
@endif
</td>
@if (Auth::check() && Auth::user()->level == 'admin')
<td style="overflow: hidden; width: 210px;">
<div class="box-button">
{{ link_to('edition/' . $edition->id . '/edit', 'Edit', ['class' => 'btn btn-warning btn-sm']) }}
</div>
<div class="box-button">
{!! Form::open(['method' => 'POST', 'class' => 'deleteedition', 'action' => ['[email protected]', $edition->id]]) !!}
<input type="hidden" name="_method" value="DELETE">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
{!! Form::submit('Delete', ['class' => 'btn btn-danger btn-sm', 'id'=>'deleteedition1']) !!}
{!! Form::close() !!}
</div>
</td>
@endif
</tr>
<?php endforeach ?>
</tbody>
</table>
它的工作,但它將刪除列表中的整個文件,而不僅僅是一個文件,使用'return confirm()'的默認提醒工作正常,只會刪除選定的列表。 :/ –