Custom JS Script not working after section refresh
Hi,
I have created a section with some text fields and added a section which contains a button. With the click of a button, I am calling a script. And I have added the script in Harness. The script looks as follows :
var button;
button= document.querySelector('.button button'); // Added a class inside button to get button element
button.addEventListener("click",Init);
function Init(){
console.log("test");
pega.u.d.reloadSection(pega.u.d.getSectionByName("Testcustomer","",""),"",'', false, true, '-1', false);
/* var options = {
section: "Testcustomer"
};
pega.api.ui.actions.refreshSection(options);*/
}
I have tried both reload section and refresh section API. So If I click on the button for the first time I can see messages in the console and refresh is happening but after that, If I click on the button again the script is not executing.
Can you please help me out? If I am missing something.