Kentico MVC Form. Javascript changes are lost on Submit.

Daniel Nistreanu asked on October 24, 2019 12:26

Hi! The Problem: I use Kentico 12 MVC. Whenever I click submit button, custom javascript(dom manipulation) changes are lost.

Context Info: I had to style Kentico Forms(Form Application), so regardless of what elements form contain: input fields, checkbox, radio button, phone number field, etc, elements will look in a certain way.

For that I created a custom css file and a javascript ES6 class component for dom manipulation. I use Default Form Section.

Question: How can I prevent custom javascript to be discared on click Form Submit button or to reinitialize it on form validation and after form is sended to back-end ?

Recent Answers

Zach Perry answered on October 25, 2019 16:25

I ran into a similar issue and never found a supported solution, so I just modified the Kentico js file for the form:

under Kentico/Scripts/forms/updatableFormHelper.js

i added a call to my function fixform(); after $(window).scrollTop(currentScrollPosition);

An issue with this is if you do an update or a hotfix, you may lose your changes.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.