【发布时间】:2011-05-24 06:38:06
【问题描述】:
我正在寻找一种使用 JQuery 实现可重用“确认”对话框的方法。
这是 MyApp 类中打开对话框的部分:
/**
* @param text string Message to display
*/
getConfirmationDialog: function(text) {
MyApp.confirmDialog = $('<div><p>' + text + '</p></div>');
MyApp.confirmDialog
.dialog({
modal: true,
autoOpen: false,
title: 'Please confirm',
width: 300,
height: 180,
buttons: {
'OK': function() {
return true;
},
Cancel: function() {
$(this).dialog('close');
return false;
}
}
});
MyApp.confirmDialog.dialog('open');
},
我在另一堂课上:
/**
* Clear system cache
*
* @param url string Backend URL
*/
clearCache: function(url) {
dialog = MyApp.getConfirmationDialog('Clear cache?');
//dialog returns true..
if (dialog) {
MyApp.admin.dashboard.doClearCache();
}
},
但我不知道以“正确”的方式执行此操作.. 对话框无法返回值还是?
【问题讨论】:
标签: jquery jquery-ui confirm-dialog