【发布时间】:2020-11-29 16:33:44
【问题描述】:
我有一系列从数据库中填充的项目。我想在每个上都放一条甜蜜的更改状态确认消息。如何将他们的 ID 传递到 sweetalert 确认消息中?
在该部分中,我有一个功能,如果他们确认消息,我想运行它,如果他们不确认,我不希望它做任何事情。我在页面底部有以下代码,单击链接时会触发该代码。但是,我需要将 productID 传递到警报中,以便可以在 updateProducts 函数中调用它。
$(`.link`).click(function () {
swal({
title: "Are you sure?",
text: "Are you sure you want to change the status?",
icon: "warning",
buttons: true,
dangerMode: true,
}).then((confirm) => {
if (confirm) {
updateProducts(productID);
} else {
swal("The status has not changed.");
}
});
})
【问题讨论】:
标签: javascript jquery sweetalert sweetalert2