jquery clean old dialog

前端 未结 3 1124
盖世英雄少女心
盖世英雄少女心 2021-01-22 16:37

I am trying to use UI dialog to create a modal dialog.

The dialog workscorrectly, and all is well. I close the dialog using the \"X\" in the corner. I tried using

3条回答
  •  有刺的猬
    2021-01-22 17:20

    You can clear all input elements dynamically.

    $("#New_WorkBoard_Dialog input[type='text']").each(function(index, element) {
        $(element).val("");
    )};
    

    If you prefer, you can clear it on close event of the dialog:

    $('#New_WorkBoard_Dialog').dialog({
    autoOpen: false,
    height: 530,
    width:300,
    modal: true,
    resizable:false,
    buttons: {
        Cancel: function() {
            $(this).dialog('close');
             //$('#New_WorkBoard_Dialog').dialog('destroy');
        },
        'Register board': function() {
            var board_name=document.getElementById("name");
            var comments=document.getElementById("comment");
            Createboard(board_name,comments);
            $(this).dialog('close');
    
        }
    
    },
    close: function() {
        $("#New_WorkBoard_Dialog input[type='text']").each(function(index, element) {
            $(element).val("");
        )};
    }
    });
    

提交回复
热议问题