*

Osclass2024

  • **
  • 15 posts
How to avoid post duplication by quickly pressing the publish button two or three times?

*

MB Themes

Ideal scenario is to disable publish button once clicked or add some additionsl jquery check.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Osclass2024

  • **
  • 15 posts
Perfect, thank MB Themes.

I solved it in the following way:


in file item-post.php make the following changes:

replace line 54

Code: [Select]
<form name="item" action="<?php echo osc_base_url(true);?>" method="post" enctype="multipart/form-data" id="item-post">
for

Code: [Select]
<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

Code: [Select]
<button type="submit" class="btn btn-primary pbl"><?php if($edit) { _e("Update"'sigma'); } else { _e("Publish"'sigma'); } ?></button>
for

Code: [Select]
<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


Code: [Select]
<script>
    function disableButton() {
        document.getElementById("submitButton").disabled = true;
        return true; // Devuelve true para permitir que el formulario se envĂ­e
    }
</script>









*

MB Themes

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
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Osclass2024

  • **
  • 15 posts

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