0

I am initialising a jQuery-UI dialog with close function defined as below:

$("#msg").dialog({
  width: '390',
  height: '320',
  modal: true,
  autoOpen: false,
  closeOnEscape: false,
  resizable: false,
  close: function (event, ui) { 
    window.location = "http://www.somewere.com"; 
  }
});

This dialog was being called from numerous places and since the logic was to always redirect after giving the user the message, so I placed it in initialisation.

Now the requirement is to change just one logic where the workflow will be on the same page.

How can I disable the close function just before opening this dialog?

Shiladitya
  • 12,003
  • 15
  • 25
  • 38
Ratna
  • 2,289
  • 3
  • 26
  • 50

2 Answers2

0

I think you can do this:

$("#msg").dialog({
  width: '390',
  height: '320',
  modal: true,
  autoOpen: false,
  closeOnEscape: false,
  resizable: false,
  close: function (event, ui) { 
    window.location = "http://www.somewere.com"; 
  },
  open: function(){
    this.close = function(){};
  }
});

Though, the close will not be disabled on before opening, it will be disabled after opening, but that shouldn't be a problem.

Shiladitya
  • 12,003
  • 15
  • 25
  • 38
Amit Joki
  • 58,320
  • 7
  • 77
  • 95
0

write down inside close function as :

close:function(event, ul){
   $(this).dialog('close');
   return false;
}
Maneesh Singh
  • 555
  • 2
  • 12