1

jquery ui ダイアログを使用しています。ダイアログには1つの保存ボタンがあり、ユーザーが保存ボタンのコールバックで保存ボタンをクリックすると、無効になります。私のコード:

$("#Form1").dialog({
    width: 500, autoOpen: false, modal: true, resizable: false, draggable: false,
    buttons: {
        "Save": function (event, ui) {
            $(event.currentTarget).button({ disabled: true });
             ... .
             ....
         }
    }
    , beforeClose: function () {
        //here how can i enable the save button
    }
});

今私の問題は、ユーザーがダイアログを再度開いたときに保存ボタンがまだ無効になっているため、ダイアログbeforeCloseイベントでボタンを有効にしたいということです。これどうやってするの?

4

2 に答える 2

1

ダイアログを呼び出す要素は親にラップされるため、タイトル バーやボタンなどを追加できます。すべてのボタンにクラスがありますui-button

これはあなたが必要とすることをするはずです

beforeClose:function(){
   $(this).parent().find('.ui-button').button({ disabled: false });

}
于 2012-10-30T11:56:35.650 に答える
0

次の方法でボタンを有効または無効にする方が簡単な場合があります。

btn_save = $('#Form1').parent().find(':button:contains("save")');

//disable the save button
$(btn_save).prop('disabled', true).addClass('ui-state-disabled');

//enable the save button
$(btn_save).prop('disabled', false).removeClass('ui-state-disabled');

追加された css クラスにより、ボタンの css スタイルが無効になります。:containsまた、セレクターでは大文字と小文字が区別されることに注意してください。

于 2012-10-30T11:58:33.150 に答える