mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-02-15 16:58:42 +00:00
allow formaction in buttons
This commit is contained in:
parent
bf803f6919
commit
8f49a37a70
|
|
@ -177,7 +177,7 @@ export class Form {
|
||||||
submits[i].addEventListener('click', function (event)
|
submits[i].addEventListener('click', function (event)
|
||||||
{
|
{
|
||||||
jsOMS.preventAll(event);
|
jsOMS.preventAll(event);
|
||||||
self.submit(self.forms[id]);
|
self.submit(self.forms[id], submits[i].getAttribute('formaction'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -235,14 +235,17 @@ export class Form {
|
||||||
*
|
*
|
||||||
* Calls injections first before executing the actual form submit
|
* Calls injections first before executing the actual form submit
|
||||||
*
|
*
|
||||||
* @param {Object} form Form object
|
* @param {Object} form Form object
|
||||||
|
* @param {string} action Action different from the form action (e.g. formaction=*)
|
||||||
*
|
*
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
submit (form)
|
submit (form, action)
|
||||||
{
|
{
|
||||||
|
action = typeof action !== 'undefined' ? action : null;
|
||||||
|
|
||||||
/* Handle injects */
|
/* Handle injects */
|
||||||
const self = this,
|
const self = this,
|
||||||
injects = form.getSubmitInjects();
|
injects = form.getSubmitInjects();
|
||||||
|
|
@ -252,7 +255,7 @@ export class Form {
|
||||||
// Register normal form behavior
|
// Register normal form behavior
|
||||||
this.app.eventManager.attach(form.getId(), function ()
|
this.app.eventManager.attach(form.getId(), function ()
|
||||||
{
|
{
|
||||||
self.submitForm(form);
|
self.submitForm(form, action);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
// Run all injects first
|
// Run all injects first
|
||||||
|
|
@ -280,14 +283,16 @@ export class Form {
|
||||||
*
|
*
|
||||||
* Submits the main form data
|
* Submits the main form data
|
||||||
*
|
*
|
||||||
* @param {Object} form Form object
|
* @param {Object} form Form object
|
||||||
*
|
* @param {string} action Action different from the form action (e.g. formaction=*)
|
||||||
* @return {void}
|
* @return {void}
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
submitForm (form)
|
submitForm (form, action)
|
||||||
{
|
{
|
||||||
|
action = typeof action !== 'undefined' ? action : null;
|
||||||
|
|
||||||
if (!form.isValid()) {
|
if (!form.isValid()) {
|
||||||
this.app.notifyManager.send(
|
this.app.notifyManager.send(
|
||||||
new NotificationMessage(
|
new NotificationMessage(
|
||||||
|
|
@ -315,7 +320,7 @@ export class Form {
|
||||||
|
|
||||||
request.setData(form.getData());
|
request.setData(form.getData());
|
||||||
request.setType(ResponseType.JSON);
|
request.setType(ResponseType.JSON);
|
||||||
request.setUri(form.getAction());
|
request.setUri(action ? action : form.getAction());
|
||||||
request.setMethod(form.getMethod());
|
request.setMethod(form.getMethod());
|
||||||
request.setRequestHeader('Content-Type', 'application/json');
|
request.setRequestHeader('Content-Type', 'application/json');
|
||||||
request.setSuccess(function (xhr)
|
request.setSuccess(function (xhr)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user