Skip to content

Commit 6564842

Browse files
committed
Merge pull request #84 from manuelj555/submit-form
Allow event handling in submitForm
2 parents 30f9be0 + e902e08 commit 6564842

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Resources/public/js/FpJsFormValidator.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ function FpJsFormElement() {
110110

111111
this.onValidate = function (errors, event) {
112112
};
113+
114+
this.submitForm = function (form) {
115+
form.submit();
116+
};
113117
}
114118

115119
function FpJsAjaxRequest() {
@@ -272,13 +276,13 @@ function FpJsCustomizeMethods() {
272276
FpJsFormValidator.ajax.callbacks.push(function () {
273277
element.onValidate.apply(element.domNode, [FpJsFormValidator.getAllErrors(element, {}), event]);
274278
if (element.isValid()) {
275-
item.submit();
279+
element.submitForm.apply(item, [item]);
276280
}
277281
});
278282
} else {
279283
element.onValidate.apply(element.domNode, [FpJsFormValidator.getAllErrors(element, {}), event]);
280284
if (element.isValid()) {
281-
item.submit();
285+
element.submitForm.apply(item, [item]);
282286
}
283287
}
284288
});

Resources/public/js/fp_js_validator.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ function FpJsFormElement() {
110110

111111
this.onValidate = function (errors, event) {
112112
};
113+
114+
this.submitForm = function (form) {
115+
form.submit();
116+
};
113117
}
114118

115119
function FpJsAjaxRequest() {
@@ -272,13 +276,13 @@ function FpJsCustomizeMethods() {
272276
FpJsFormValidator.ajax.callbacks.push(function () {
273277
element.onValidate.apply(element.domNode, [FpJsFormValidator.getAllErrors(element, {}), event]);
274278
if (element.isValid()) {
275-
item.submit();
279+
element.submitForm.apply(item, [item]);
276280
}
277281
});
278282
} else {
279283
element.onValidate.apply(element.domNode, [FpJsFormValidator.getAllErrors(element, {}), event]);
280284
if (element.isValid()) {
281-
item.submit();
285+
element.submitForm.apply(item, [item]);
282286
}
283287
}
284288
});

0 commit comments

Comments
 (0)