I am using alertify.confirm()
in my spring mvc project.
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. Why is this happening?
Alertify's confirm
has four parameters , not three: 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:
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. Consider using native HTML5 <dialog>
instead .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.