Support Forum
Support › MB Frontend Submission › Prevent scroll to form
Hello,
How do I prevent the page from scrolling to the top of the form when using Ajax submit?
I am embedding my form in a pop-up, and so I don’t want the page content to scroll while the modal is open.
Based on this discussion (https://stackoverflow.com/questions/9538868/prevent-body-from-scrolling-when-a-modal-is-opened#11013994), I could probably make something work by using some JavaScript to apply a class to the body and then do some CSS work from there. However, it would be nice if I could simply turn the scrolling behavior off rather than try to override it.
Thanks!
Hello there,
After submitting a form, the page will scroll to the form message and it is the standard behavior. I will inform the development team to consider supporting an option to disable this action.
Hi Peter,
I know that is the default behavior. Can you share how it works so that I can try to override it?
Thanks,
Graceson
Hi Peter,
I figured out a quick and very dirty fix. I simply deleted r("html, body").animate({scrollTop:a.offset().top-50},200),
from frontend-submission.js. This should work until the next update, but it is by no means a proper solution.
Can you please include this feature, or suggest a more robust work-around?
Thanks,
Graceson
@Anh Tran
Do you have any suggestions for this use case? My theme now prevents the user from scrolling the page while the modal is open, but the form submission still scrolls. Therefore, I think I need a solution that prevents MB Fontend Submission from running the animate scroll function that is in frontend-submission.js.
Is there a more robust way for me to override this feature rather than modifying the source code itself? Or, will I need to wait for a new feature to be hopefully implemented first?
Thanks,
Graceson
Hello,
I've created a feature request for the development team. They will consider supporting this in future updates and I will inform you when I have any information.