EasyUI Forum

General Category => Bug Report => Topic started by: mshaffer on November 19, 2016, 03:34:45 AM



Title: $.messager.alert fn doesn't trigger on "x-close"
Post by: mshaffer 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.



Title: Re: $.messager.alert fn doesn't trigger on "x-close"
Post by: jarry 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')
}
});


Title: Re: $.messager.alert fn doesn't trigger on "x-close"
Post by: mshaffer on November 19, 2016, 07:31:30 AM
Yes, this appears to work...  Thank you!   ::)

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();}
});


Title: Re: $.messager.alert fn doesn't trigger on "x-close"
Post by: sky-t 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


Title: Re: $.messager.alert fn doesn't trigger on "x-close"
Post by: jarry 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.


Title: Re: $.messager.alert fn doesn't trigger on "x-close"
Post by: sky-t 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?


Title: Re: $.messager.alert fn doesn't trigger on "x-close"
Post by: jarry on December 16, 2016, 12:01:28 AM
Please look at this example http://code.reloado.com/ixeyux3/edit#preview