我只是在写一些代码,遇到了这样的问题:
alertify.dialog("confirm").set(
{
'labels':
{
ok: 'Personal',
cancel: 'Share'
},
'message': 'Select target:',
'onok': function()
{
alertify.confirm($("#dir_select_user").get(0), function()
{
var i = $("#dir_select_user .dir_selector").val();
t.find(".move_des").val(i);
t.find(".move_verify").val("1");
t.submit();
}).set('labels',
{
ok: alertify.defaults.glossary.ok,
cancel: alertify.defaults.glossary.cancel
});
},
'oncancel': function()
{
alertify.confirm($("#dir_select_share").get(0), function()
{
var i = $("#dir_select_share .dir_selector").val();
t.find(".move_des").val(i);
t.find(".move_verify").val("1");
t.submit();
}).set('labels',
{
ok: alertify.defaults.glossary.ok,
cancel: alertify.defaults.glossary.cancel
});
}
}) }).show();我使用alertifyjs库来自http://alertifyjs.com (而不是来自http://fabien-d.github.io/alertify.js/)。
如果您尝试这段代码,您会发现“onok”和“oncancel”对话框在选择personal或share后迅速消失。
这里有什么问题?我该怎么解决呢?
发布于 2015-02-02 14:55:54
问题的根源在于,当对话框被关闭时,您正在尝试再次显示相同的对话框。默认的AlertifyJS对话框都是单例(任何时候都有一个实例)。
对此您有两个解决方案:
参见演示这里。
https://stackoverflow.com/questions/28278829
复制相似问题