jquery clean old dialog

前端 未结 3 1130
盖世英雄少女心
盖世英雄少女心 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 16:58

    If you want to reopen it again just use this code again:

    $('#New_WorkBoard_Dialog').dialog('open');
    

    Don't bother destroying and reinitializing the dialog. There's no need for that.

    0 讨论(0)
  • 2021-01-22 17:00

    As Ra Yell said, is better to clean it before closing it, this way you don't have to worry about it when you open the dialog again.

    $('input').val('');
    

    The previous instruction worked for me.

    0 讨论(0)
  • 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("");
        )};
    }
    });
    
    0 讨论(0)
提交回复
热议问题