EasyUI Forum
May 03, 2024, 02:15:40 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: Confirmation dialog on panel onBeforeClose  (Read 8045 times)
glarsen
Newbie
*
Posts: 39


View Profile Email
« on: June 09, 2014, 01:49:22 PM »

Would like the get confirmation from the user to close a window.  When I use the async messager dialog in the onBeforeClose event the window closes as soon as the dialog appears.

What's the best way to program around this? 

Thanks,
gary
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: June 09, 2014, 06:31:37 PM »

All the $.messager functions work in async mode. This means that the user can't block it before doing any more. To make the confirm message window works like a native confirm window in 'onBeforeClose' event, please try the code below:
Code:
$('#win').window({
  onBeforeClose:function(){
    var p = $(this);
    $.messager.confirm('Confirm','Are you sure you want to close?',function(r){
      if (r){
        var opts = p.panel('options');
        var onBeforeClose = opts.onBeforeClose;
        opts.onBeforeClose = function(){};
        p.panel('close');
        opts.onBeforeClose = onBeforeClose;
      }
    });
    return false;
  }
})
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!