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 AlertifyJS hasn't been significantly updated in six years, I think you should consider using a different dialog library. Consider using native HTML5 <dialog>
instead.