使用关闭按钮关闭 toastr 时阻止事件。
Prevent event when toastr closed with close button.
在我的应用程序中使用 toastr.js,我有这样的流程,当用户提交表单时,我需要显示 toast 并给他一些时间通过单击关闭按钮关闭此 toast,以防止将数据发送到服务器,但如果他不关闭toast,应该发送数据。
我有这样的问题:
toastr.options = {
closeButton: true,
onHidden: () => { //send data to the server },
onCloseClick: () => { console.log('you clicked close button') },
}
toastr.success('success');
问题是 onHidden 方法总是会触发。
请帮忙!
好心人帮帮我!
解决方案是:
isPrevented = false;
toastr.options = {
closeButton: true,
onHidden: () => {
if (isPrevented) {
return false;
} else {
//Sent result to server;
}
},
onCloseClick: () => {
isPrevented = true
}
}
感谢所有贡献者! )
在我的应用程序中使用 toastr.js,我有这样的流程,当用户提交表单时,我需要显示 toast 并给他一些时间通过单击关闭按钮关闭此 toast,以防止将数据发送到服务器,但如果他不关闭toast,应该发送数据。
我有这样的问题:
toastr.options = {
closeButton: true,
onHidden: () => { //send data to the server },
onCloseClick: () => { console.log('you clicked close button') },
}
toastr.success('success');
问题是 onHidden 方法总是会触发。 请帮忙!
好心人帮帮我! 解决方案是:
isPrevented = false;
toastr.options = {
closeButton: true,
onHidden: () => {
if (isPrevented) {
return false;
} else {
//Sent result to server;
}
},
onCloseClick: () => {
isPrevented = true
}
}
感谢所有贡献者! )