我有javascript确认工作内联和功能,但无法弄清楚如何使用PNotify确认对话框实现。理想情况下,我可以用pconfirm('Sure?')替换confirm('Sure?')并返回true / false。它是.Net app,主要用于onClientClick事件,以确认LinkButton执行客户端。
PNotify确认和取消事件仅在pconfirm返回false时触发:
function pconfirm(title){
(new PNotify({
title: title,
icon: 'glyphicon glyphicon-question-sign',
hide: false,
confirm: {
confirm: true
},
buttons: {
closer: false,
sticker: false
},
history: {
history: false
},
addclass: 'stack-modal',
stack: {
'dir1': 'down',
'dir2': 'right',
'modal': true
}
})).get().on('pnotify.confirm', function() {
//alert('ok');
return true;
}).on('pnotify.cancel', function() {
//alert('cancel');
return false;
});
return false;
}
我创建了Fiddle,使用了javascript并且失败了PNotify:
答案 0 :(得分:1)
回答了我自己的问题:
$(".confirmLink").click(function(e) {
e.preventDefault();
var targetUrl = $(this).attr("href");
(new PNotify({
title: $(this).data("title") || 'Are you sure?',
icon: 'glyphicon glyphicon-question-sign',
hide: false,
confirm: {
confirm: true
},
buttons: {
closer: false,
sticker: false
},
history: {
history: false
},
addclass: 'stack-modal',
stack: {
'dir1': 'down',
'dir2': 'right',
'modal': true
}
})).get().on('pnotify.confirm', function() {
window.location.href = targetUrl;
}).on('pnotify.cancel', function() {
// do nothing
});
});