[英]Why alertify confirm cancel button not working?
我在我的 spring mvc 项目中使用alertify.confirm()
。
alertify.confirm(
"Press OK to Confirm",
function(){ console.log("ok") },
function(){ console.log("canceled") });
但是每当我按下OK
或CANCEL
按钮时,它都会在控制台中打印“ok”。 为什么会这样?
Alertify的confirm
有四个参数,不是三个: title: string, message: string, onOK: function, onCancel: function )
将您的代码更改为:
alertify.confirm(
/*title: */ "Confirm low-effort stackoverflow posting"
/*message:*/ "Press OK to Confirm posting a question to stackoverflow without doing a quick 15-seconds google search",
/*ok: */ function(){ console.log("ok") },
/*cancel: */ function(){ console.log("canceled, good, the world is better for you having done your research first") }
);
我确实在他们的文档页面中看到了 3 个参数的重载,[但是 Alertify 的confirm.js][2]
将onok
参数重新用于oncancel
- 我认为这是一个错误:
main: function (_title, _message, _onok, _oncancel) {
var title, message, onok, oncancel;
switch (arguments.length) {
case 1:
message = _title;
break;
case 2:
message = _title;
onok = _message;
break;
case 3:
message = _title;
onok = _message;
oncancel = _onok;
break;
case 4:
title = _title;
message = _message;
onok = _onok;
oncancel = _oncancel;
break;
}
this.set('title', title);
this.set('message', message);
this.set('onok', onok);
this.set('oncancel', oncancel);
return this;
},
鉴于 AlertifyJS在六年内没有显着更新,我认为您应该考虑使用不同的对话框库。 考虑使用原生 HTML5 <dialog>
代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.