@acanto/core-forms
Advanced tools
Comparing version 0.0.20 to 0.0.21
18
base.js
import ajax from "@acanto/core-ajax"; | ||
import { getPostData, getFormData } from "@acanto/core-fillform/helpers"; | ||
import { $ } from "@acanto/core-dom"; | ||
import { $, getDataAttr } from "@acanto/core-dom"; | ||
import Validation from "./validation"; | ||
@@ -15,2 +15,3 @@ import scrollTo from "@acanto/core-scroll/scrollTo"; | ||
const $form = /** @type {HTMLFormElement} */ ($(selector, $root)); | ||
$root = $root || $form; | ||
const $submit = /** @type {HTMLButtonElement} */ ($( | ||
@@ -24,9 +25,10 @@ "[type='submit']", | ||
}; | ||
const hasAjaxSubmit = !!getDataAttr($form, "ajax-submit"); | ||
// init form validation | ||
const validation = Validation($form, { | ||
onerror: handleInvalidSubmit, | ||
onsuccess: handleValidSubmit, | ||
}); | ||
const validationOptions = { onerror: handleInvalidSubmit }; | ||
if (hasAjaxSubmit) validationOptions.onsuccess = handleValidSubmit; | ||
const validation = Validation($form, validationOptions); | ||
/** | ||
@@ -50,8 +52,4 @@ * Handle invalid submission attempt (before sending to server) | ||
* Handle valid submit | ||
* | ||
* @param {Event} event | ||
*/ | ||
function handleValidSubmit(event) { | ||
event.preventDefault(); | ||
function handleValidSubmit() { | ||
onSubmitStart(); | ||
@@ -58,0 +56,0 @@ |
{ | ||
"name": "@acanto/core-forms", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"author": "Acanto <info@acanto.net> (https://acanto.agency/)", | ||
@@ -31,3 +31,3 @@ "license": "ISC", | ||
], | ||
"gitHead": "cf1139977b72cc52ac4d695156b5f0cfd12abb26" | ||
"gitHead": "b16d6ca996dd00482d7499252f13660cf1ea560a" | ||
} |
Sorry, the diff of this file is not supported yet
109498
1671