Dialog box hide() and show() -- Jquery?
Asked Answered
M

3

7

Iam using 3 dialogs in my page for 3 diff purpose.

Iam creating dialog as

  $(".dialog").dialog({
        height: 238,
        width: 465,
        resizable: false,
        title: "Edit"
    });

After my action done on dialog iam closing dialog as

   $(".ui-dialog").hide();

When i hide this way dialog is not getting opening for 2nd time, So tried showing dialog starting of function like

  $(".ui-dialog").show();

My problem started here....

When i show dialog, Dialogs are getting opened multiple times, STill the first openined dialog is getting Overlapped wth the second dialog,

Is there any proper way to hide and Show dialog without overlapping or in clean way.

Mercaptopurine answered 28/6, 2013 at 6:34 Comment(0)
B
28

You need to use the close(hide) and open(show) functions provided by the widget

$(".ui-dialog").dialog('close');
$(".ui-dialog").dialog('open');
Basinet answered 28/6, 2013 at 6:38 Comment(1)
But here it is not working properly., Mayb due to improper placement of these conditionsFly
C
8

If you just want to hide/show a dialog without closing it you can use

$(".dialog").parent().hide()
$(".dialog").parent().show()
Claus answered 9/12, 2015 at 21:40 Comment(0)
F
3

To show/hide the dialog we need to use open/close methods

//To close the dialog use 'close' method.
//It will hide the dialog. Your html and data still exist in the DOM  
$("#my_dialog_id").dialog('close');   

//Show closed dialog again if it is still exists and not destroyed the
$("#my_dialog_id").dialog('open');

//This method totally destroy your dialog. Element will be returned to pre-init state
$("#my_dialog_id").dialog('destroy');

//To check if the dialog is open or not 
var isOpen = $( "#my_dialog_id" ).dialog( "isOpen" );
Figwort answered 18/6, 2018 at 2:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.