Use ajax for form requests too.

This commit is contained in:
Jan Böhmer 2019-03-24 20:25:27 +01:00
parent b3db1dd139
commit 8711f296a4
6 changed files with 43 additions and 4 deletions

View file

@ -75,6 +75,7 @@ class AjaxUI {
{
console.info("AjaxUI started!");
this.registerLinks();
this.registerForm();
}
/**
@ -95,6 +96,26 @@ class AjaxUI {
console.debug('Links registered!');
}
/**
* Register all forms for loading via ajax.
*/
protected registerForm()
{
let options : JQueryFormOptions = {
success: this.onAjaxComplete,
beforeSubmit: function (arr, $form, options) : boolean {
//When data-with-progbar is specified, then show progressbar.
if($form.data("with-progbar") != undefined) {
ajaxUI.showProgressBar();
}
return true;
}
}
$('form').not('[data-no-ajax]').ajaxForm(options);
console.debug('Forms registered!');
}
public showProgressBar()
{
@ -204,6 +225,7 @@ class AjaxUI {
//Do things on the new dom
ajaxUI.registerLinks();
ajaxUI.registerForm();
}