Jump to content

Bulk Edit disable and relabel Update button needs redirect url inserted


Recommended Posts

Hi, the below code is to disable and relabel the Update button in Bulk Edit when it is clicked (it's a datapage with a lot of records and takes several seconds to update so the user needs to know what's happening and not click the Update button more than once). This code is in the footer of the Results page and not the Bulk Edit form. 

I need to add the additional code (see below) that redirects to another webpage and I can't figure out where/how to insert it into the disable/relabel code. Does anyone know how to do this? 

Here's the disable/relabel code for the Update button in Bulk Edit: 

<script>
document.addEventListener('DataPageReady', function (event) {
const target = document.querySelector('body');
const observer = new MutationObserver(mutations => {
const updateBtn = document.querySelector('input[value="Update"]');
if(updateBtn){
updateBtn.addEventListener('click',function(){
disable(this);
redirectToDP(this);
});
}
});
const config = {subtree:true, childList:true};
observer.observe(target, config);

function disable(btn){
btn.disabled = true;
btn.style.background="grey";
btn.value = 'Please Wait';
btn.removeEventListener('click',disable);
}
});
</script>

Here's the code in the Bulk Edit footer for redirecting (I think it needs to be there because I have to get parameters from the Bulk Edit data fields): 

<script>

function redirectToDP() {

var v_proposal = document.getElementById("BulkEditItems_Triggers_CopyProposalID").value;

var v_project = document.getElementById("BulkEditItems_Triggers_CopyProjectID").value;

var url = "../proposal?ProposalID=" + v_proposal + "&ProjectID=" + v_project + "&pti=p";

   location.replace(url);
}
</script>

I tried to call the function 'redirectToDP' from the disable/relabel code but it doesn't work. Does anyone know how to get the redirect code to work with the disable/relabel code? Many thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...