我怎样才能在 Sweet Alert 弹出消息内容中获得价值?
How can I do get value in Sweet Alert Poppup Message Content?
我使用 JQUERY Datatable js 和 SweetAlert.js
当点击 id 获取 id 并显示 sweet alert confirm 弹出窗口时,数据表中有一个删除图标。当单击是时,它删除了正常工作。
我想获取有关 id 的信息 = "TITLE" 值到警告消息内容。
数据表
<tbody>
<tr>
<td>@item.TITLE</td>
<td>
**<a href="javascript:void(0);" onclick="deleteuser('@item.id')"><i class="fa fa-trash-o"></i></a>**
</td>
</tr>
</tbody>
SWEETALERT Js code This Point get need here (bold marked value) => text: "@TITLE are u want delete!" id title text should come here
function deleteuser(userid) {
swal({
title: "Are u sure?",
text: "@TITLE are u want delete!",
icon: "warning",
buttons: {
cancel: {
text: "No, iptal!",
value: null,
visible: true,
className: "",
closeModal: false,
},
confirm: {
text: "Yes, sil!",
value: true,
visible: true,
className: "",
closeModal: false
}
}
})
你可以这样实现:
<tbody id="my-table">
<tr>
<td class="title">Some Title</td>
<td>
<a href="javascript:void(0);" class="delete-btn" data-id="@item.id"><i class="fa fa-trash-o"></i></a>
</td>
</tr>
</tbody>
稍后 javascript:
$('#my-table').on('click', '.delete-btn', function(){
var deleteBtn = $(this),
id = deleteBtn.data('id'),
title = deleteBtn.closest('tr').find('.title').text();
swal({
title: "Are u sure?",
text: title + " are u want delete!",
icon: "warning",
buttons: {
cancel: {
text: "No, iptal!",
value: null,
visible: true,
className: "",
closeModal: false,
},
confirm: {
text: "Yes, sil!",
value: true,
visible: true,
className: "",
closeModal: false
}
}
})
});
我使用 JQUERY Datatable js 和 SweetAlert.js
当点击 id 获取 id 并显示 sweet alert confirm 弹出窗口时,数据表中有一个删除图标。当单击是时,它删除了正常工作。
我想获取有关 id 的信息 = "TITLE" 值到警告消息内容。
数据表
<tbody>
<tr>
<td>@item.TITLE</td>
<td>
**<a href="javascript:void(0);" onclick="deleteuser('@item.id')"><i class="fa fa-trash-o"></i></a>**
</td>
</tr>
</tbody>
SWEETALERT Js code This Point get need here (bold marked value) => text: "@TITLE are u want delete!" id title text should come here
function deleteuser(userid) {
swal({
title: "Are u sure?",
text: "@TITLE are u want delete!",
icon: "warning",
buttons: {
cancel: {
text: "No, iptal!",
value: null,
visible: true,
className: "",
closeModal: false,
},
confirm: {
text: "Yes, sil!",
value: true,
visible: true,
className: "",
closeModal: false
}
}
})
你可以这样实现:
<tbody id="my-table">
<tr>
<td class="title">Some Title</td>
<td>
<a href="javascript:void(0);" class="delete-btn" data-id="@item.id"><i class="fa fa-trash-o"></i></a>
</td>
</tr>
</tbody>
稍后 javascript:
$('#my-table').on('click', '.delete-btn', function(){
var deleteBtn = $(this),
id = deleteBtn.data('id'),
title = deleteBtn.closest('tr').find('.title').text();
swal({
title: "Are u sure?",
text: title + " are u want delete!",
icon: "warning",
buttons: {
cancel: {
text: "No, iptal!",
value: null,
visible: true,
className: "",
closeModal: false,
},
confirm: {
text: "Yes, sil!",
value: true,
visible: true,
className: "",
closeModal: false
}
}
})
});