I am using Sharepoint online 2015. During creating a list item, I need to save the list item and redirect the page to EditForm.aspx of the created list item instead of AllItems.aspx.
Following is the html code for the button:
<button type="button" id="idSaveProceed">Save & Proceed</button>
Following is the jQuery code for saving the list item and redirecting it to Edit form:
$("#idSaveProceed").click(function(event){
event.preventDefault();
if (!PreSaveItem()) return false;
if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", "", false, true));
GetListItemId(); // This will redirect the page to EditFoem.aspx;
});
But when the code if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2'))
executes, the page redirect is happening to AllItems.aspx. I have even given custom url in WebForm_DoPostBackWithOptions
. But before that code get executed, page is getting redirected.
I have tried using event.preventdefault()
but of no use.
Kindly let me know what am missing here. Thanks in advance.
Note: I do not want to use InfoPath. I just want a solution in jQuery to handle this.