gpt4 book ai didi

dialog - 在alertify确认对话框中添加自定义按钮

转载 作者:行者123 更新时间:2023-12-02 05:34:09 24 4
gpt4 key购买 nike

我正在使用 Alertify js 1.6.1 在用户离开页面时显示对话框。除了确定和取消之外,我还需要在alertify js确认对话框中添加一个额外的按钮“继续”。有没有办法添加自定义按钮功能?如果您对此有任何想法,请告诉我。谢谢

最佳答案

您可以构建自己的或扩展现有的确认:

    alertify.dialog('myConfirm', function() {
var settings;
return {
setup: function() {
var settings = alertify.confirm().settings;
for (var prop in settings)
this.settings[prop] = settings[prop];
var setup = alertify.confirm().setup();
setup.buttons.push({
text: '<u>C</u>ontinue',
key: 67 /*c*/ ,
scope: 'auxiliary',
});
return setup;
},
settings: {
oncontinue: null
},
callback: function(closeEvent) {
if (closeEvent.index == 2) {
if (typeof this.get('oncontinue') === 'function') {
returnValue = this.get('oncontinue').call(this, closeEvent);
if (typeof returnValue !== 'undefined') {
closeEvent.cancel = !returnValue;
}
}
} else {
alertify.confirm().callback.call(this, closeEvent);
}
}
};
}, false, 'confirm');

参见example

关于dialog - 在alertify确认对话框中添加自定义按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36006284/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com