EasyUI Forum
December 21, 2025, 07:16:49 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How can I show a confirm message before submit form data?  (Read 15424 times)
Stefan B.
Full Member
***
Posts: 152


Software Architekt


View Profile Email
« on: June 27, 2014, 03:28:10 AM »

How can I show a confirm message before submit form data and if the result of confirm is false to cancel the submit action?
The following code is not working while the $.messager.confirm() working asynchronous.

Code:
	    onSubmit: function(param){ //Fires before submit, return false to prevent submit action.
    if($(this).form('validate') == false) { //validate form data
    $.messager.alert(infoTitleInvalidInput, infoTitleInvalidMsg, "error");
    return false;
    };
   
    $.messager.confirm(infoTitleConfirm, confirmEdit, function(r){
if (r) {  return true;}
    });
return false;
    },
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 27, 2014, 06:16:00 PM »

Please try this:
Code:
$('#ff').form({
onSubmit:function(){
var f = this;
var opts = $.data(this, 'form').options;
if($(this).form('validate') == false){
return false;
}
$.messager.confirm('Confirm','Are you sure?',function(r){
if (r){
var onSubmit = opts.onSubmit;
opts.onSubmit = function(){};
$(f).form('submit');
opts.onSubmit = onSubmit;
}
})
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!