javascript – Jquery dialog to open multiple windows – Education Career Blog

I’m trying to make system of multiple dialogs in one page using jquery dialog…

Functions looks like…

 function open_w(id){

         $('.opened').dialog('close');
         $(id).addClass('opened');
         $(id).dialog({position: 'center',  modal:true, width: '750px' });
           };


     function close_w(){
     $('.opened').dialog('close');
     $('.opened').removeClass('opened');
      };

As you see passing the ID opens me that windows, but before open close me old windows.. When i open it fist time everything is good.. But Next time it’s doesn’t want open

Where is mistake?

,

It’s because you’re trying to re-create the dialog, instead of this every time:

$(id).dialog({position: 'center',  modal:true, width: '750px' });

You need to call open (on the already created dialog), like this:

$(id).dialog('open');

For example:

function open_w(id){
  close_w();
  $(id).addClass('opened')
       .dialog({position: 'center',  modal:true, width: '750px' })
       .dialog('open');
}
function close_w() {
  $('.opened').dialog('close').removeClass('opened');
}

Leave a Comment