如何從函數中禁用 jQuery 對話框中的按鈕? - How can I disable a button in a jQuery dialog from a function?

問題:

I have a jQuery dialog that requires the user to enter certain information.我有一個 jQuery 對話框,需要用戶輸入某些信息。 In this form, I have a "continue" button.在這種形式中,我有一個“繼續”按鈕。 I would like this "continue" button to only be enabled once all the fields have content in them, else it will remain disabled.我希望這個“繼續”按鈕只有在所有字段都包含內容後才啓用,否則它將保持禁用狀態。

I wrote a function that is called everytime a field status has changed.我編寫了一個函數,每次字段狀態發生變化時都會調用該函數。 However, I don't know how to enable and disable the dialog button from this function.但是,我不知道如何從此功能啓用和禁用對話框按鈕。 What should I do?我該怎麼辦?

Oops and I forgot to mention that these buttons were created as follows:哎呀,我忘了提到這些按鈕是按如下方式創建的:

$(function() {
  $("#dialog").dialog({
    bgiframe: true,
    height: 'auto',
    width: 700,
    show: 'clip',
    hide: 'clip',
    modal: true,
    buttons: {
      'Add to request list': function() {
        $(this).dialog('close');
        $('form').submit();
      },
      'Cancel': function() {
        $(this).dialog('close');
      }
    }
  })
});

解決方案:

參考一: https://stackoom.com/question/2QFI
參考二: How can I disable a button in a jQuery dialog from a function?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章