Submit the form instead of refreshing the page

This commit is contained in:
Narek Zakarian 2024-03-05 18:56:38 +04:00
parent da6d57b77b
commit 982b0e950d
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -15,15 +15,25 @@ document.addEventListener( 'DOMContentLoaded', () => {
headingRow.parentNode.insertBefore(newRow, headingRow.nextSibling); headingRow.parentNode.insertBefore(newRow, headingRow.nextSibling);
saveChangesButton.addEventListener('click', () => { let isSaving = false; // Flag variable to track whether saving is in progress
form.querySelector('.' + publishButtonClassName).click();
// Delay the page refresh by a few milliseconds to ensure changes take effect saveChangesButton.addEventListener('click', () => {
setTimeout(() => { // Check if saving is not already in progress
location.reload(); if (!isSaving) {
}, 1000); isSaving = true; // Set flag to indicate saving is in progress
// Trigger the click event on the publish button
form.querySelector('.' + publishButtonClassName).click();
// Trigger click event on saveChangesButton after a short delay
setTimeout(() => {
saveChangesButton.click(); // Trigger click event on saveChangesButton
isSaving = false; // Reset flag when saving is complete
}, 500); // Adjust the delay as needed
}
}); });
merchantConfigurators.Messaging({ merchantConfigurators.Messaging({
config: PcpPayLaterConfigurator.config, config: PcpPayLaterConfigurator.config,
merchantClientId: PcpPayLaterConfigurator.merchantClientId, merchantClientId: PcpPayLaterConfigurator.merchantClientId,