そのため、AJAX を介して送信し、成功したかどうかにかかわらずダイアログを表示する機能があります。すべて正常に動作しますが、そのダイアログ関数に追加機能を実行する追加機能 (オプション) を渡すオプションが必要です。ここに私が持っているものがあります:
// the work
if (data._response.success == 'true') {
$("#suppliers_grid").trigger("reloadGrid");
$('#manage-suppliers-form').fullFormReset();
alertDialog('Supplier '+ action +' successfully!','Success',$('#manage-suppliers-form :input:visible:first').focus());
} else {
alertDialog('Supplier was not '+ action +' successfully!<br />Please try again or report this to the administrator.','Error','ui-state-error');
}
// the alertDialog function
function alertDialog(message,title,cssClass,closeFunction) {
title = typeof title !== 'undefined' ? title : 'Notice';
cssClass = typeof cssClass !== 'undefined' ? cssClass : 'ui-state-highlight';
if (cssClass=='ui-state-error') {
icon = 'ui-icon-alert';
}
else {
icon = 'ui-icon-info';
}
var dialog = $('<div><p><span class="ui-icon '+ icon +'"></span>'+ message +'</p></div>');
dialog.dialog({
modal: true,
title: title,
buttons: {
Ok: function() { $(this).dialog("close"); }
},
close: closeFunction()
});
}
1) closeFunction を渡すと、上記は機能しません
2)何かを渡さずにテストしていませんが、どちらも機能しないと確信しています。closeFunction は OPTIONAL にする必要があります
3) alertDialog 呼び出しの後にコードの「フォーカス」行を単純に配置することはできません。これは機能しますが(バックグラウンドでフォーカスを取得します)。誰かが alertDialog で「OK」をクリックするとすぐに、フォーカスが失われるため、alertDialog の終了時に呼び出す必要があります。