我已经搜索并找不到解决方案。希望我忽略了一些简单的事情。
我所追求的是一个标准的 jquery 确认,一个 la:
$('.confirm').click(function(){
var answer = confirm('Delete '+jQuery(this).attr('title'));
return answer // answer is a boolean
});
但是,我想将 SimpleModal 用于警报窗口。如果在 SimpleModal 对话框中单击“是”,除了尝试让原始 href 继续进行之外,我可以让 SimpleModal 出现并工作。
目前的代码......
jQuery(function ($) {
$('.confirm').click(function (e) {
e.preventDefault();
confirm("", function () {
//alert('yes');
$('.confirm').trigger('click');
});
});
});
function confirm(message, callback) {
$('#confirm').modal({
closeHTML: "<a href='#' title='Close' class='modal-close'>x</a>",
position: ["20%",],
overlayId: 'please-wait',
containerId: 'confirm-container',
onShow: function (dialog) {
var modal = this;
$('.message', dialog.data[0]).append('Delete '+$('a.confirm').attr('title'));
// if the user clicks "yes"
$('.yes', dialog.data[0]).click(function () {
// call the callback
if ($.isFunction(callback)) {
callback.apply();
}
// close the dialog
modal.close();
});
}
});
}
我还在确认功能中注释掉了一个警报。警报确实有效。但是如何让浏览器继续原来的href?
谢谢!