Support Forums - Classified Ads Script Osclass
Osclass theme support => Sigma Osclass Theme => Topic started by: Osclass2024 on March 27, 2024, 07:32:44 PM
-
How to avoid post duplication by quickly pressing the publish button two or three times?
-
Ideal scenario is to disable publish button once clicked or add some additionsl jquery check.
-
Perfect, thank MB Themes.
I solved it in the following way:
in file item-post.php make the following changes:
replace line 54
<form name="item" action="<?php echo osc_base_url(true);?>" method="post" enctype="multipart/form-data" id="item-post">
for
<form name="item" action="<?php echo osc_base_url(true);?>" method="post" enctype="multipart/form-data" id="item-post" onsubmit="return disableButton()">
replace line 259
<button type="submit" class="btn btn-primary pbl"><?php if($edit) { _e("Update", 'sigma'); } else { _e("Publish", 'sigma'); } ?></button>
for
<button id="submitButton" type="submit" class="btn btn-primary pbl"><?php if($edit) { _e("Update", 'sigma'); } else { _e("Publish", 'sigma'); } ?></button>
and add end file
<script>
function disableButton() {
document.getElementById("submitButton").disabled = true;
return true; // Devuelve true para permitir que el formulario se envĂe
}
</script>
-
But you should enable it back within 5 seconds or on any input change .... as validations could be done on submit and if any jquery validation fails, user may not be able to submit form anymore
-
but when you send the form it would reload again, and when it reloads again it would appear activated, or could it be that when you send the form it does not reload the page? In this theme, from what I saw, it does not use ajax to send the form without recharge it after shipping