【发布时间】:2011-07-20 03:36:01
【问题描述】:
我有这个代码:
$('.b-icon.b-icon_del').click(function(e) {
showConfirmDialog('Are you sure you want to delete this document?',deleteDocument(window.lastSelectedRowId), 'Delete document');
});
function showConfirmDialog(content, callback, pTitle, obj){
return showDialogEx(content, callback, pTitle, obj, "Yes", "No");
}
function showDialogEx(content, callback, pTitle, obj, okButtonLabel, cancelButtonLabel){
var str = "#_showMessageDialog";
var showMessageDialog = $(str);
if(showMessageDialog.length == 0){
$('body').append('<div id="_showMessageDialog"></div>');
showMessageDialog = $(str);
}
showMessageDialog.val("");
showMessageDialog.append('<p id="_showMessageDialogContent">'.concat(content, '</p>'));
var my_buttons = {};
my_buttons[cancelButtonLabel] = function(){
$(this).dialog("close");
$(this).html("");
$(this).dialog("destroy");
};
my_buttons[okButtonLabel] = function(){
callback();
$(this).html("");
$(this).dialog("close");
if(obj){
obj.focus();
}
$(this).dialog("destroy");
};
showMessageDialog.dialog({
modal : true,
resizable : true,
title : pTitle,
minWidth : 250,
width : 450,
buttons : my_buttons
});
}
然后我单击带有.b-icon.b-icon_del 类的按钮,目前似乎同时执行deleteDocument(window.lastSelectedRowId) 和showConfirmDialog('Are you sure you want to delete this document?',deleteDocument(window.lastSelectedRowId), 'Delete document');
。我只想在用户单击“确定”按钮后调用该回调函数(deleteDocument(window.lastSelectedRowId))。谢谢!
【问题讨论】:
标签: javascript jquery jquery-ui jquery-plugins jdialog