@hortonstudio/main 1.7.3 → 1.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autoInit/form.js +23 -0
- package/index.js +1 -1
- package/package.json +1 -1
package/autoInit/form.js
CHANGED
|
@@ -651,6 +651,29 @@ export function init() {
|
|
|
651
651
|
finalAnimElement.click();
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// Check for custom redirect before allowing natural submission
|
|
655
|
+
if (formWrapper && formWrapper.hasAttribute('data-hs-form-redirect')) {
|
|
656
|
+
const redirectUrl = formWrapper.getAttribute('data-hs-form-redirect');
|
|
657
|
+
|
|
658
|
+
if (redirectUrl && redirectUrl.trim()) {
|
|
659
|
+
// Prevent the natural form submission
|
|
660
|
+
event.preventDefault();
|
|
661
|
+
event.stopPropagation();
|
|
662
|
+
event.stopImmediatePropagation();
|
|
663
|
+
|
|
664
|
+
// Perform the redirect
|
|
665
|
+
try {
|
|
666
|
+
window.location.href = redirectUrl.trim();
|
|
667
|
+
} catch (error) {
|
|
668
|
+
console.error('Form redirect failed:', error);
|
|
669
|
+
// Fallback: allow natural form submission if redirect fails
|
|
670
|
+
form.submit();
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
return false;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
654
677
|
// Prevent submission if configured to do so
|
|
655
678
|
if (shouldPreventSubmit) {
|
|
656
679
|
event.preventDefault();
|
package/index.js
CHANGED