Avoid duplicating posts
Categories:
Avoid duplicating posts
This code is very useful to avoid duplicated posts in your Drupal site. Some times when users try to submit a form, the form will take more than usual to reload or to respond. In those cases you want to have the submit button to disappear and to show a message saying that the form is being processed. I found this piece of code somewhere in the durpal.org site. I have been using it all the time and works like a charm.
This is a jQuery snippet and goes inside a block or page or node.
<?php
$data = '$(document).ready(function() {
$("input[@type=submit]").click(function() {
$(this).siblings("input[@type=submit]").hide();
$(this).hide();
$("<p class=\"loading\">Waiting for response…</p>").insertAfter(this).slideDown("fast");
});
});';
// don't allow users to post content more than once
drupal_add_js(
$data ,
'inline'
);
?>- 75 reads
Post new comment