how to maintain page scroll position in form when onsubmit | Community
Skip to main content
srinivas_channa
Level 2
October 16, 2015
Solved

how to maintain page scroll position in form when onsubmit

  • October 16, 2015
  • 3 replies
  • 1476 views
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>
 
 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

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. 

3 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

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. 

srinivas_channa
Level 2
October 16, 2015

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>

smacdonald2008
Level 10
October 16, 2015

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