views:

638

answers:

2

Hi All,

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 dialog('destroy').remove(); , but then of course I can't open it again. I think I just don't understand how to reinitialize the dialog and do not have the old values in it.

function CreateWorkBoard()

{ var jsmarty = WMCreateSmartyObject(); var param = { MY_NAME1:GLOBAL_MY_NAME1, MY_NAME2:GLOBAL_MY_NAME2, LANG_NAME:LANGUAGE_NAME, BOARD_DIALOG_TITLE:WM_LANG_BOARD_DIALOG_BOARD_DIALOG_TITLE, BOARD_TITLE: WM_LANG_BOARD_DIALOG_BOARD_TITLE, COMMENT_TITLE:WM_LANG_BOARD_DIALOG_COMMENT_TITLE, MEMBERS_TITLE:WM_LANG_BOARD_DIALOG_MEMBERS_TITLE, CANCEL_BUTTON:WM_LANG_BOARD_DIALOG_CANCEL_BUTTON, REGISTER_BUTTON:WM_LANG_BOARD_DIALOG_REGISTER_BUTTON

};
jsmarty.assign('LANG', param);
var divValue = WMSmartyFetch(jsmarty, 'createBoardDialog.tpl');
document.getElementById('CREATE_DIALOG').innerHTML = divValue;
jsmarty.clear_all_assign();
//alert(document.getElementById('CREATE_DIALOG').innerHTML);
//alert(divValue);

//$.ui.dialog.defaults.bgiframe = true;
//alert(document.getElementById('New_WorkBoard_Dialog').innerHTML);
$('#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').dialog('open');

}

A: 

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.

RaYell
-1: that's what I said :)
Mickel
It reopens this way but it does not clear the last entered values.How can i do it withourt destroying it.
Clear the values yourself: `$('input,textarea,select').val('');`
RaYell
A: 

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.

MexicanHacker