AlertifyJS有一个放置辅助按钮的地方。
当我的辅助按钮被点击时,我希望有两件事发生
我该怎么做这两件事?
通过将通知作为第三个参数传递,我可以获得显示通知,但是对话框消失了。而且,如果我有多个辅助按钮和每个辅助按钮的不同功能,这是行不通的。
下面是我的javascript和这是一个JSFiddle。
// Run this function when the auxiliary button is clicked
// And do not close the dialog
var helpInfo = function () {
alertify.notify("help help help");
};
var custom = function () {
if (!alertify.helper) {
alertify.dialog('helper', function factory() {
return {
setup: function () {
return {
buttons: [{
text: 'Help',
scope: 'auxiliary'
}],
options: {
modal: false
}
};
}
};
}, false, 'alert');
}
alertify.helper('Do you need help?', "hello world", helpInfo);
};
custom();发布于 2015-03-06 18:22:09
AlertifyJS回调将被传递给一个特殊的closeEvent对象。要使对话框保持打开状态,回调应该将cancel属性设置为true或简单地设置为return false。
var helpInfo = function (closeEvent) {
alertify.notify("help help help");
closeEvent.cancel = true;
//or
//return false;
};请参阅更新Fiddle
发布于 2015-03-06 17:52:47
向helpInfo函数添加一个附加参数,以便您可以访问与事件一起传递的事件对象。现在,您可以防止它的默认操作(这将关闭对话框)。
var helpInfo = function (e) {
alertify.notify("help help help");
e.preventDefault();
};https://stackoverflow.com/questions/28904057
复制相似问题