以下是打开对话框的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();
}
},
但我不知道应该用“正确”的方式来做这件事.. 对话框不能返回值吗?