et2.submit(button,async) button can now be widget-id too, new optional async parameter to send request asynchronious (default synchronious), eg. to show an otherwise frozen animation

This commit is contained in:
Ralf Becker 2013-10-30 14:07:29 +00:00
parent 69ecce26d7
commit 064baf926a

View File

@ -354,7 +354,14 @@ etemplate2.prototype.isDirty = function()
return dirty; return dirty;
}; };
etemplate2.prototype.submit = function(button) /**
* Submit form via ajax
*
* @param et2_button|string button button widget or string with id
* @param boolean async true: do an asynchronious submit, default is synchronious
* @return boolean true if submit was send, false if eg. validation stoped submit
*/
etemplate2.prototype.submit = function(button, async)
{ {
// Get the form values // Get the form values
var values = this.getValues(this.widgetContainer); var values = this.getValues(this.widgetContainer);
@ -370,6 +377,10 @@ etemplate2.prototype.submit = function(button)
if (canSubmit) if (canSubmit)
{ {
if (typeof button == 'string')
{
button = this.widgetContainer.getWidgetById(button);
}
// Button parameter used for submit buttons in datagrid // Button parameter used for submit buttons in datagrid
// TODO: This should probably go in nextmatch's getValues(), along with selected rows somehow. // TODO: This should probably go in nextmatch's getValues(), along with selected rows somehow.
// I'm just not sure how. // I'm just not sure how.
@ -410,7 +421,7 @@ etemplate2.prototype.submit = function(button)
if (this.menuaction) if (this.menuaction)
{ {
var api = this.widgetContainer.egw(); var api = this.widgetContainer.egw();
var request = api.json(this.menuaction, [this.etemplate_exec_id,values], null, this); var request = api.json(this.menuaction, [this.etemplate_exec_id,values], null, this, async);
request.sendRequest(); request.sendRequest();
} }
else else
@ -418,6 +429,7 @@ etemplate2.prototype.submit = function(button)
this.widgetContainer.egw().debug("warn", "Missing menuaction for submit. Values: ", values); this.widgetContainer.egw().debug("warn", "Missing menuaction for submit. Values: ", values);
} }
} }
return canSubmit;
}; };
/** /**