EasyUI Forum
April 18, 2024, 09:02:48 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: $.messager.alert fn doesn't trigger on "x-close"  (Read 11853 times)
mshaffer
Newbie
*
Posts: 21


View Profile
« on: November 19, 2016, 03:34:45 AM »

Code:
$.messager.alert	title, msg, icon, fn	Show an alert window. Parameters:
title: The title text to be showed on header panel.
msg: The message text to be showed.
icon: The icon image to be showed. Available value are: error,question,info,warning.
fn: The callback function triggered when window closed.
Code example:

$.messager.alert('My Title','Here is a info message!','info');

This messenger alert "fn" works as expected if I click "OK", but if I click on the "X" in the top right corner it doesn't call the "fn" (e.g., cancel and ok may be different functions).

A true alert, whether you click on "ok" or "x" should call the function, IMO.  If not, I need an ability to remove the "X" from the top right corner, or define the same fn as "fn2" or something.

Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: November 19, 2016, 05:51:52 AM »

Please try this code instead.
Code:
$.messager.alert({
title: 'My Title',
msg: 'Here is a message!',
onClose: function(){
console.log('onClose')
},
fn: function(){
console.log('ok')
}
});
Logged
mshaffer
Newbie
*
Posts: 21


View Profile
« Reply #2 on: November 19, 2016, 07:31:30 AM »

Yes, this appears to work...  Thank you!   Roll Eyes

Code:
$.messager.alert({title: 'Logout: System Idle',
msg: 'For your security, the system has logged you out due to inactivity',
onClose: function(){ alertLogout(); },
icon: 'info',
fn: function(){ alertLogout();}
});
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #3 on: December 15, 2016, 02:46:49 AM »

When i hitting the ESC-Key the messager closes and the function onClose is not executing.
Is there a hint to catch the ESC-Key?

Thank you
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #4 on: December 15, 2016, 08:25:49 AM »

When press the ESC key on a message dialog, the 'onClose' event fires. Please check your code carefully.
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #5 on: December 15, 2016, 09:29:06 AM »

                  $.messager.defaults.ok = 'Ok';
                  $.messager.alert({
                     title: 'test',
                     msg: 'message',
                     icon:'error',
                     onClose: function(){
                        window.location = "url";
                     },
                     fn: function(){
                        window.location = "url";
                     }
                  });

When clicking Ok or clicking the x (Close-Button) it works.
On ESC the messager hides without calling the onClose function.

What i'm doing wrong?
« Last Edit: December 15, 2016, 09:31:06 AM by sky-t » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #6 on: December 16, 2016, 12:01:28 AM »

Please look at this example http://code.reloado.com/ixeyux3/edit#preview
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!