EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Hoffiric on September 28, 2015, 04:00:38 AM



Title: Actually submit forms
Post by: Hoffiric on September 28, 2015, 04:00:38 AM
Hello

I can't seem to find a way to submit forms the normal way (you know; static POSTs). The only way I've found is by adding an actual submit input tag which then skips the whole form validation.

Asynchronous form POSTs are super annoying because they force you to soft-code the recovery path to the view instead of just having an URL for one result. It's just like infinite pages like the ones Youtube; it sucks horrible and results in the worst usability one could create with such modern tools at hand.

Please help me find a way to properly submit a form using the EasyUI validation and whatnots. The documentation does not contain a word about this, it's all about callbacks.

Thank you!


Title: Re: Actually submit forms
Post by: stworthy on September 28, 2015, 08:17:01 PM
If you wish to submit a form synchronously, call the .submit() method when validated successfully.
Code:
$('#ff').form({
onSubmit: function(){
var isValid = $(this).form('validate');
if (isValid){
this.submit();
}
return false;
}
})


Title: Re: Actually submit forms
Post by: Hoffiric on September 29, 2015, 02:49:24 AM
Thanks for the code example.

I see now that I can do the validation myself, which is good.

Another issue I have found is that there seems to be no Return/Enter to submit for a form. That is mainly because EasyUI does not use an actual submit button for submitting forms, I assume. Is there a way around this or will I have to catch the return key myself and invoke the forms submit?


Title: Re: Actually submit forms
Post by: stworthy on September 30, 2015, 06:08:56 PM
You can add a hidden submit button in the form.
Code:
<form action="...">
  ...
  <input type="submit" value="submit" style="visibility:hidden">
</form>