Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

how to maintain page scroll position in form when onsubmit

Avatar

Level 2
I am using the blog page and when I feed a comment  I see that it is calling
 
/libs/collab/commons/components/comments/formular.html.jsp
 
My problem is that when comment is submitted with an error (fileds not filled that onsubmit  javascript method returns a false)
 
the scroball always goes to the top instead of staying at the same position where it is .
 
Please let me know how to solve it
 
The form I am using
<form onsubmit="return false;" method="POST" name="comment" enctype="multipart/form-data" class="comment" > ... </form>
 
 
1 Accepted Solution

Avatar

Correct answer by
Level 10

You will have to modify the form component (/libs/foundation/components/form) and add custom Javascript logic  to keep The Scroll Position after a Submission Is performed. If You Google this topic, there are quite a few discussions on this topic. 

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

You will have to modify the form component (/libs/foundation/components/form) and add custom Javascript logic  to keep The Scroll Position after a Submission Is performed. If You Google this topic, there are quite a few discussions on this topic. 

Avatar

Level 2

Thanks for your input. let me know if in below form I could do any modifications  ,like adding a script to some attribute which could solve this issue,instead of going to (/libs/foundation/components/form)

<form onsubmit="return false;" method="POST" name="comment" enctype="multipart/form-data" class="comment" > ... </form>

Avatar

Level 10

Sure you can -- you can use JQuery lib (assuming there is one you want to use). Everything in AEM is essentially Javascript. FOr example - you can create forms using JavaScript frameworks. Here for example is an AEM form that is based on JQuery Mobile API:

http://helpx.adobe.com/experience-manager/using/submitting-mobile-form-data-cq.html