我正在使用 sweet alert 库,但取消按钮有问题。这是我的甜蜜警报代码:
sweetAlert({
title: title,
text: text + ' ' + courseList,
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: confirmButtonText,
cancelButtonText: "Continue with purchase",
closeOnConfirm: false,
closeOnCancel: false,
html: true
},
function(isConfirm) {
if (isConfirm) {
angular.forEach(repeatedCourses, function(repeatedCourse) {
$rootScope.$apply(function() {
this.removeCoursePurchase(repeatedCourse);
}.bind(this));
}.bind(this));
$rootScope.$broadcast('uncheckCheckboxes');
swal("Deleted!", "Your purchase has been refreshed.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
}.bind(this));
当用户点击确认按钮时,工作正常,但如果点击取消按钮不做任何事情,它不会出现“已取消”框,我不知道为什么!
最佳答案
删除附加到回调函数的 .bind(this),它将起作用。
关于javascript - 甜蜜警报不适用于取消按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29843222/