Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Prevent form position reset upon save Topic is solved
Prevent form position reset upon save
I have a custom 'Save' button on my form and it works fine. However, when the button is clicked the data is saved but the form gets scrolled to the top of the page. I'd like to stay in the same place where I was before I clicked the 'Save' button. How do I accomplish this?
Re: Prevent form position reset upon save
Hi Paul,
You could place this in the Form's Browse & Edit or Edit JavaScript.
Steven
You could place this in the Form's Browse & Edit or Edit JavaScript.
Code: Select all
if(window.previousID != null || window.previousID === undefined){
$('#'+window.previousID).focus();
}
document.addEventListener('focusout', (event) => {
if(event.target.id != 'nuSaveButton'){
window.previousID = event.target.id;
}
});
Steven
A short post is a good post.
Re: Prevent form position reset upon save
If I put the 'Save' button near the bottom of the form, then the provided code works. However, if I place it in the middle of the form, then it does not.
Re: Prevent form position reset upon save
Hi Paul,
I'm unclear on what you are trying to do.
You said
Steven
I'm unclear on what you are trying to do.
You said
Can you share some screen shots?If I put the 'Save' button near the bottom of the form,
Steven
A short post is a good post.
-
- nuBuilder Team
- Posts: 4449
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 488 times
- Contact:
Re: Prevent form position reset upon save
Also try this approach:
Code: Select all
if (nuHasBeenSaved() > 0) {
// Restore the scroll position
window.scrollTo(0, window.scrollTop);
}
function nuBeforeSave() {
// Get current vertical scroll position
window.scrollTop = window.scrollY;
return true; // Allow the save to proceed
}
Re: Prevent form position reset upon save
I have two Save buttons on the form, one in the middle and one near the bottom. The form is a long one. That is the reason why I want additional Save buttons.
Per your instructions, I have placed your code (first version) in the Form's Browse & Edit JavaScript area.
If I click the first one, focus jumps to the top - not what I want.
If I click on the lower one, the focus remains where it is.
Per your instructions, I have placed your code (first version) in the Form's Browse & Edit JavaScript area.
If I click the first one, focus jumps to the top - not what I want.
If I click on the lower one, the focus remains where it is.
Last edited by Paul on Thu Sep 04, 2025 6:24 am, edited 1 time in total.
Re: Prevent form position reset upon save
The second bit of code works. Tried it several times with both Save buttons. Thanks!
-
- nuBuilder Team
- Posts: 4449
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 488 times
- Contact:
Re: Prevent form position reset upon save
Instead of adding more Save buttons, make the Action Holder—the toolbar with actions like Save and Delete—sticky so it stays visible at the top as you scroll down the page.
To do so, add the following CSS under Setup → Style:
To do so, add the following CSS under Setup → Style:
Code: Select all
.nuBreadcrumbHolder {
position: sticky;
top: 0;
z-index: 1000;
}
.nuActionHolder {
position: sticky;
top: 33px;
z-index: 999;
}