diff --git a/app/javascript/contact_us_form.js b/app/javascript/contact_us_form.js index 6dcd401..5ae9f14 100644 --- a/app/javascript/contact_us_form.js +++ b/app/javascript/contact_us_form.js @@ -1,12 +1,14 @@ document.addEventListener("turbolinks:load", function () { - var form = document.getElementById('contact-us-form'); - form.addEventListener('submit', function (e) { - document.getElementById("contact-us-form-submit-button").classList.add('is-hidden'); - document.getElementById("contact-us-form-loading-state").classList.remove('is-hidden'); - }); + var form = document.getElementById('contact-us-form'); + if (!form) { return; } - form.addEventListener('tinyforms:submitted', function(e) { - form.classList.add('is-hidden'); - document.getElementById("contact-us-form-success-message").classList.remove('is-hidden'); - }) + form.addEventListener('submit', function (e) { + document.getElementById("contact-us-form-submit-button").classList.add('is-hidden'); + document.getElementById("contact-us-form-loading-state").classList.remove('is-hidden'); + }); + + form.addEventListener('tinyforms:submitted', function(e) { + form.classList.add('is-hidden'); + document.getElementById("contact-us-form-success-message").classList.remove('is-hidden'); + }); }); \ No newline at end of file diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 6f4362a..df33706 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -188,7 +188,7 @@

We are building tinyforms to make your work easier! Let us know what we can do for you.

-
@@ -201,7 +201,7 @@
- +
@@ -211,13 +211,16 @@
-
\ No newline at end of file