EasyUI Forum
May 14, 2024, 01:53:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to check if one dialog exists? (Singleton Pattern)  (Read 6602 times)
eagleeye
Newbie
*
Posts: 19


View Profile Email
« on: April 08, 2016, 07:14:52 AM »

Hi partners have a nice day, i have one div to show one dialog  it is created fine when is called for first time, but when is called in subsecuent times one error appear .

My question is  How to check if it dialog exists?, if it exists only must be showed and not created .

Code:
<div id="dialog_cambiaPassword"></div>

My function for create the dialog is it:

Code:
function openDialog() {
   
    //var dialog_pass = $("#dialog_cambiaPassword");
   
       var dlg =  $('#dialog_cambiaPassword').dialog({
            title: 'AgendaNet',
            width: 400,
            height: 200,
            closed: true,
            resizable: false,
            href: 'cambiaPassword.html',
            modal: true,
            buttons: [
                {
                    iconCls: 'icon-save',
                    text: 'Grabar',
                    handler: function () {
                        alert('save');
                    }
                },
                {
                    iconCls: 'icon-cancel',
                    text: 'Cancelar',
                    handler: function () {
                        //$('#dialog_cambiaPassword').dialog('close');
                        //$('#dialog_cambiaPassword').dialog('destroy');
                         dlg.dialog('destroy')
                    }
                }
            ]
        });
         $('#dialog_cambiaPassword').dialog('open');
}
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: April 09, 2016, 02:07:01 AM »

Try this code:
Code:
var dlg = $("#dialog_cambiaPassword");
if (dlg.data('dialog')){ // the dialog has been created
...
} else {
dlg.dialog({
...
})
}
Logged
eagleeye
Newbie
*
Posts: 19


View Profile Email
« Reply #2 on: April 11, 2016, 06:35:38 AM »

Thanks it works fine!!!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!