Support Forums - Classified Ads Script Osclass

Osclass theme support => Sigma Osclass Theme => Topic started by: Osclass2024 on March 27, 2024, 07:32:44 PM

Title: How to avoid post duplication by quickly pressing the publish button two or thre
Post 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?
Title: Re: How to avoid post duplication by quickly pressing the publish button two or thre
Post by: MB Themes on March 27, 2024, 07:39:05 PM
Ideal scenario is to disable publish button once clicked or add some additionsl jquery check.
Title: Re: How to avoid post duplication by quickly pressing the publish button two or thre
Post by: Osclass2024 on April 03, 2024, 08:45:52 PM
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>








Title: Re: How to avoid post duplication by quickly pressing the publish button two or thre
Post by: MB Themes on April 05, 2024, 03:18:18 PM
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
Title: Re: How to avoid post duplication by quickly pressing the publish button two or thre
Post by: Osclass2024 on April 10, 2024, 02:26:55 PM

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