表单提交后无法阻止页面重定向
Unable to prevent page redirect after form submit
我正在使用 Sharepoint online 2015。在创建列表项期间,我需要保存列表项并将页面重定向到创建的列表项的 EditForm.aspx 而不是 AllItems.aspx。
以下是按钮的 html 代码:
<button type="button" id="idSaveProceed">Save & Proceed</button>
以下是 jQuery 用于保存列表项并将其重定向到编辑表单的代码:
$("#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;
});
但是当代码 if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2'))
执行时,页面重定向发生在 AllItems.aspx。我什至在 WebForm_DoPostBackWithOptions
中给出了自定义 url。但是在执行该代码之前,页面正在重定向。
我试过使用 event.preventdefault()
但没有用。
请告诉我这里缺少什么。提前致谢。
注意:我不想使用 InfoPath。我只想要 jQuery 中的解决方案来处理这个问题。
您正在post填写客户经理声明中的表格。
这将调用服务器端代码而不转到下一行。
您可以使用 Ajax 调用发送表单 post 调用,然后重定向页面。
点击事件结束时return为false
$("#idSaveProceed").click(function(event){
if (!PreSaveItem()) return false;
if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", "", false, true));return false;});
您还需要更新
< form id="aspnetForm" action="< url >?Source=...">
源参数
看看这个 url。
http://formsdesigner.blogspot.in/2013/04/redirect-after-sharepoint-form.html
但很好奇您将如何获取新提交的项目 ID?
我正在使用 Sharepoint online 2015。在创建列表项期间,我需要保存列表项并将页面重定向到创建的列表项的 EditForm.aspx 而不是 AllItems.aspx。
以下是按钮的 html 代码:
<button type="button" id="idSaveProceed">Save & Proceed</button>
以下是 jQuery 用于保存列表项并将其重定向到编辑表单的代码:
$("#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;
});
但是当代码 if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2'))
执行时,页面重定向发生在 AllItems.aspx。我什至在 WebForm_DoPostBackWithOptions
中给出了自定义 url。但是在执行该代码之前,页面正在重定向。
我试过使用 event.preventdefault()
但没有用。
请告诉我这里缺少什么。提前致谢。
注意:我不想使用 InfoPath。我只想要 jQuery 中的解决方案来处理这个问题。
您正在post填写客户经理声明中的表格。
这将调用服务器端代码而不转到下一行。
您可以使用 Ajax 调用发送表单 post 调用,然后重定向页面。
点击事件结束时return为false
$("#idSaveProceed").click(function(event){
if (!PreSaveItem()) return false;
if (SPClientForms.ClientFormManager.SubmitClientForm('WPQ2')) return false;
WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(elementName, "", true, "", "", false, true));return false;});
您还需要更新
< form id="aspnetForm" action="< url >?Source=...">
源参数
看看这个 url。 http://formsdesigner.blogspot.in/2013/04/redirect-after-sharepoint-form.html
但很好奇您将如何获取新提交的项目 ID?