[英]Why alertify confirm cancel button not working?
I am using alertify.confirm()
in my spring mvc project.我在我的 spring mvc 项目中使用
alertify.confirm()
。
alertify.confirm(
"Press OK to Confirm",
function(){ console.log("ok") },
function(){ console.log("canceled") });
But whenever i press OK
or CANCEL
button, it prints "ok" in the console.但是每当我按下
OK
或CANCEL
按钮时,它都会在控制台中打印“ok”。 Why is this happening?为什么会这样?
Alertify's confirm
has four parameters , not three: title: string, message: string, onOK: function, onCancel: function )
Alertify的
confirm
有四个参数,不是三个: title: string, message: string, onOK: function, onCancel: function )
Change your code to this:将您的代码更改为:
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") }
);
I do see an overload with 3 parameters in their documentation page , [however the source-code of Alertify's confirm.js][2]
re-uses the onok
parameter for oncancel
- I think that's a bug:我确实在他们的文档页面中看到了 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;
},
Given that AlertifyJShasn't been significantly updated in six years , I think you should consider using a different dialog library.鉴于 AlertifyJS在六年内没有显着更新,我认为您应该考虑使用不同的对话框库。 Consider using native HTML5
<dialog>
instead . 考虑使用原生 HTML5
<dialog>
代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.