I have been trying to get this to work, to no avail. I am wanting a button similar to the save button in 2013. This "Save and Stay" button would submit the form with data currently filled out for the page, but then redirect back to itself so that the user could continue to fill out the form if they would like. Below is what I have attempted.
I tried this first by just copying the save button and modifying some parameters, this just acted like the save button and would redirect as normal:
<input type="button" name="ctl00$ctl39$g_52193838_579d_4f8b_ba08_4d04594a729e$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItemAndStay" value="Save and Stay" onclick="if (!PreSaveItem()) return false;if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl39$g_52193838_579d_4f8b_ba08_4d04594a729e$ctl00$toolBarTbl$RightRptControls$ctl00$ctl00$diidIOSaveItemAndStay", "", true, "", window.location.href, false, true))" id="ctl00_ctl39_g_52193838_579d_4f8b_ba08_4d04594a729e_ctl00_toolBarTbl_RightRptControls_ctl00_ctl00_diidIOSaveItemAndStay" accesskey="O" class="ms-ButtonHeightWidth" target="_self">
Then I tried adding a button through javascript/jquery, and this would act like it would submit and return to the page, but the data would not get saved to the database and would disappear once the user left the page:
var button = $("input[id$=SaveAndStay]");
// change redirection behavior
button.click(function() {
console.log ("button clicked");
if (!PreSaveItem()) return false;
SP.UI.Notify.addNotification("Saving ...", false);
var myurl = window.location.href
$("#aspnetForm").attr('action',location.pathname+'?Source=' + myurl);
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnSaven", "", true, "", myurl, false, true));
return true;
});
Does anyone have a way to do this? I have searched on the Internet to no avail.