Skip to main content
Correction
Source Link
AymKdn
  • 1.2k
  • 8
  • 20

On Sharepoint 2013 the above methods didn't work porperly. Based on this blog post I've been able to setup the below solution (in vanilla javascript):

var elems = document.querySelectorAll('input[id$="SaveItem"]');
var redirectTo = "https://my.website.com/site/something/Pages/Wait.aspx";
for (var i=0; i<elems.length; i++) {
  // overwrite "STSNavigate()" when clicking on the save button
  elems[i].setAttribute("onclick", "STSNavigate = function(){ window.location.href = '" + redirectTo + "' }; " + elems[i].getAttribute("onclick"))
}

My form is not opening into a modal. If you open it into a modal, you may have to add the below code:

// force PostBackRequired to true in the context, otherwise it won't work if you open it into a modal
WPQ2FormCtx.PostBackRequired=true;

On Sharepoint 2013 the above methods didn't work porperly. Based on this blog post I've been able to setup the below solution (in vanilla javascript):

var elems = document.querySelectorAll('input[id$="SaveItem"]');
var redirectTo = "https://my.website.com/site/something/Pages/Wait.aspx";
for (var i=0; i<elems.length; i++) {
  // overwrite "STSNavigate()" when clicking on the save button
  elems[i].setAttribute("onclick", "STSNavigate = function(){ window.location.href = '" + redirectTo + "' }; " + elems[i].getAttribute("onclick"))
}

On Sharepoint 2013 the above methods didn't work porperly. Based on this blog post I've been able to setup the below solution (in vanilla javascript):

var elems = document.querySelectorAll('input[id$="SaveItem"]');
var redirectTo = "https://my.website.com/site/something/Pages/Wait.aspx";
for (var i=0; i<elems.length; i++) {
  // overwrite "STSNavigate()" when clicking on the save button
  elems[i].setAttribute("onclick", "STSNavigate = function(){ window.location.href = '" + redirectTo + "' }; " + elems[i].getAttribute("onclick"))
}

My form is not opening into a modal. If you open it into a modal, you may have to add the below code:

// force PostBackRequired to true in the context, otherwise it won't work if you open it into a modal
WPQ2FormCtx.PostBackRequired=true;
Source Link
AymKdn
  • 1.2k
  • 8
  • 20

On Sharepoint 2013 the above methods didn't work porperly. Based on this blog post I've been able to setup the below solution (in vanilla javascript):

var elems = document.querySelectorAll('input[id$="SaveItem"]');
var redirectTo = "https://my.website.com/site/something/Pages/Wait.aspx";
for (var i=0; i<elems.length; i++) {
  // overwrite "STSNavigate()" when clicking on the save button
  elems[i].setAttribute("onclick", "STSNavigate = function(){ window.location.href = '" + redirectTo + "' }; " + elems[i].getAttribute("onclick"))
}