EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: aswzen on October 18, 2016, 02:18:36 AM



Title: $.messager.prompt Ok and Cancel callback
Post by: aswzen on October 18, 2016, 02:18:36 AM
Where is $.messager.prompt Ok and Cancel callback

because on documentation i only found fn(val): The callback function with a value parameter user entered.

how to detect if Ok button pressed? thank you in advance


Title: Re: $.messager.prompt Ok and Cancel callback
Post by: stworthy on October 18, 2016, 08:32:21 PM
Please try this code:
Code:
$.messager.prompt('My Title', 'Please type something', function(r){
if (r === undefined){
console.log('press cancel');
} else {
console.log('press ok')
}
});


Title: Re: $.messager.prompt Ok and Cancel callback
Post by: iLLuSia on August 30, 2020, 03:12:03 PM
I wanted 3 possibilities and experimented a bit, so in case someone is ever interested in this:

Code:
$.messager.prompt('My Title', 'Please type something', function(r){
if (r) {
console.log('ok clicked, r = '+r);
} else if (r == undefined) {
console.log('cancel clicked');
} else if (r.localeCompare("")==0) {
console.log('ok clicked, but r is EMPTY');
}
});