Click save but keep form open
Hi guys.
I have added a new button to my edit form.
This button is supposed to save the form without closing the form. So the user can fill in the form and save, but still continue with the form open.
If I add:
fd.save().click();
It saves and closes the form.
Can you assist, how can I save and keep the form open?
Regards
I have added a new button to my edit form.
This button is supposed to save the form without closing the form. So the user can fill in the form and save, but still continue with the form open.
If I add:
fd.save().click();
It saves and closes the form.
Can you assist, how can I save and keep the form open?
Regards
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hello, Oz!
You can just open Edit Form again after saving it. The page will still refresh, but you will stay on the form:
This will override the save button functionality too, though.
But you can have two buttons, for example, Save and Save and Submit.
Save will refresh the page, but Save and Submit will also close the form.
You'll need to add this code to JavaScript editor:
And also add button with saveOnlyButton class to the Edit Form, so it looks like this in the end:
P.S. Make sure the form is not opened in dialog mode, otherwise the redirect will not work!
It will only work for a form opened in regular mode.
You can just open Edit Form again after saving it. The page will still refresh, but you will stay on the form:
Code: Select all
fd.onsubmit(function() {
fd.sourceFormParam('fd_Item_EditForm.aspx?ID=' + GetUrlKeyValue('ID'));
return true;
});
But you can have two buttons, for example, Save and Save and Submit.
Save will refresh the page, but Save and Submit will also close the form.
You'll need to add this code to JavaScript editor:
Code: Select all
var saveOnly = false;
$( ".saveOnlyButton" ).click(function() {
saveOnly = true;
fd.save().click();
});
fd.onsubmit(function() {
if (saveOnly)
fd.sourceFormParam('fd_Item_EditForm.aspx?ID=' + GetUrlKeyValue('ID'));
return true;
});
It will only work for a form opened in regular mode.
Cheers
Thanks Nikita - I used the second recommendation with the "saveOnlyButton".
I just needed to change the "fd_Item_EditForm.aspx" to the correct name that is on my form.
There is just one thing that I need to fix in this - hopefully with your assistance.
On the default Save button I have an a alert, the alert is written in the "OnClick" section for the button. This alert is not supposed to pop up when I hit my new button "saveOnlyButton". But as it is now this alert pops up when I click my new button.
How can I stop the alert to pop up when I click my new button?
Regards
I just needed to change the "fd_Item_EditForm.aspx" to the correct name that is on my form.
There is just one thing that I need to fix in this - hopefully with your assistance.
On the default Save button I have an a alert, the alert is written in the "OnClick" section for the button. This alert is not supposed to pop up when I hit my new button "saveOnlyButton". But as it is now this alert pops up when I click my new button.
How can I stop the alert to pop up when I click my new button?
Regards
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Hmm, you can remove alert from OnClick event and slightly change onsubmit block:
Code: Select all
fd.onsubmit(function() {
if (saveOnly)
fd.sourceFormParam('fd_Item_EditForm.aspx?ID=' + GetUrlKeyValue('ID'));
else
alert('Saving the form!');
return true;
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 15 guests