0
MVC 5アプリで作業しています。それは次のようにレンダリングされます確認後にURLに移動
@Html.ActionLink("Delete Chart " + Model[0].CurrentChartNumber,
"DeleteChartData",
new { eventId = Model[0].EventId,
chartNumber = Model[0].CurrentChartNumber },
new { @class = "btn btn-danger btnDelete" })
私のように定義されたボタンを持つ
.... ...
<a class="btn btn-danger btnDelete"
href="/AuditResults/DeleteChartData?eventId=50&chartNumber=1">
Delete Chart 1
</a>
私は削除の確認のためsweetAlertを使用しています。すべてうまく動作しますが、ユーザーが「はい」をクリックすると定義済みのhrefに移動することはできません。ここでは、ユーザーがはいをクリックした場合
<script>
$(function() {
$(".btnDelete").click(function(e) {
e.preventDefault();
swal({
title: 'Are you sure you want to DELETE this chart?',
text: "You won't be able to undo this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes!'
}).then(function() {
//user selected "Yes"
return true;
});
});
})
</script>
だから、それはへ....
/AuditResults/DeleteChartData?eventId=50&chartNumber=1
ナビゲートする必要があります...しかし、それはどこにも移動しません... javascriptのコードです。 (私はe.preventDefault()を削除して試してみました。)何が間違っているの?ありがとう!
標準の 'confirm()'で動作しますか? – Crowcoder
削除アクションはデータを変更しています。それはGETではなくPOSTでなければなりません。 –