データテーブルとアラートがポップアップするコードがあります。Datatable はアラート ポップの有無にかかわらず正常に動作しますが、アラート ポップはデータテーブルではうまく機能しません。それなしでのみ機能します(データテーブル)。これはコードの競合の可能性がありますか? このエラーは、データを削除しようとすると、users.js:27 (27 行目) で "TypeError: Cannot set property 'action' of undefined" であることを示唆しています。同じことを確認します (49 行目)。
ここに私のHTML(フォーム)コードがあります
<table class="table table-striped datatable" id="datatables">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<?php
if ($result->num_rows > 0) { // output data of each row?>
<tbody>
<?php while($row = $result->fetch_assoc()) {
if($row['status']=='t'){
?>
<form name="frmUser" action="" method="post">
<?php { //this form will display the set of pending applications
echo'<tr>';
echo '<td>' . '<input type="checkbox" name="selected[]" value="'.$row['application_number'].'" class="checkbox-warning"/>' . '</td>';
echo '<td>' . $row['application_number'] . '</td>';
echo '<td>' . $row['lastname'] . '</td>';
echo '<td>' . $row['firstname'] . '</td>';
echo'</tr>';
}
?>
<?php } //if statement
} //while statement
?>
</tbody>
</table>
<input type="button" name="delete" value="Delete" id="onDelete" />
<input type="button" name="update" value="Confirm" id="onUpdate" />
</form>
<?php
}else {
echo "0 results";
}
?>
次に、これが私のJSコードです
jQuery(document).ready(function($){
$( "#onDelete" ).click(function() {
swal({ title: "Are you sure?",
text: "You will not be able to recover this file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm){
if (isConfirm) {
document.frmUser.action = "temporary_applications_delete.php";
document.frmUser.submit();
swal("Deleted!", "Application file has been deleted.", "success");
} else {
swal("Cancelled", "Your file is safe :)", "error");
} });
});
$( "#onUpdate" ).click(function() {
swal({ title: "Are you sure?",
text: "You will UPDATE this applicant file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, UPDATE it!",
cancelButtonText: "No, cancel!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm){
if (isConfirm) {
document.frmUser.action = "temporary_applications_process.php";
document.frmUser.submit();
swal("Updated!", "Application file has been updated!.", "success");
} else {
swal("Cancelled", "Your file is safe :)", "error");
} });
});
});
コードの何が問題になったのですか?