Bug 4054 - Double-clicking the 'place hold' button can result in duplicate holds

This commit adds a new jquery function to staff-global.js, preventDoubleFormSubmit().
When used thusly: $('#form-id').preventDoubleFormSubmit();
It will prevent a submitted form from being submitted a second time.
It is currently only added to the Place Hold form in reserve/request.pl

http://bugs.koha-community.org/show_bug.cgi?id=4045
Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Tested:
Double clicking no longer causes identical double holds to be placed.
passes prove t xt t/db_dependent in line with current master.

Reminder: this will need to be added to the OPAC as well.
This commit is contained in:
Kyle Hall 2012-02-14 10:53:19 -05:00 committed by Paul Poulain
parent 5610087eca
commit a64ca0a8cf
2 changed files with 13 additions and 2 deletions

View file

@ -92,4 +92,13 @@ function checkEnter(e){ //e is event object passed from function invocation
function clearHoldFor(){ function clearHoldFor(){
$.cookie("holdfor",null, { path: "/", expires: 0 }); $.cookie("holdfor",null, { path: "/", expires: 0 });
} }
jQuery.fn.preventDoubleFormSubmit = function() {
jQuery(this).submit(function() {
if (this.beenSubmitted)
return false;
else
this.beenSubmitted = true;
});
};

View file

@ -127,6 +127,8 @@ function checkMultiHold() {
$("#requestany").attr("checked","checked"); $("#requestany").attr("checked","checked");
} }
}); });
$('#hold-request-form').preventDoubleFormSubmit();
}); });
// ]]> // ]]>
@ -238,7 +240,7 @@ function checkMultiHold() {
<fieldset class="rows left"> <fieldset class="rows left">
<legend>Hold details</legend> <legend>Hold details</legend>
[% UNLESS ( multi_hold ) %] [% UNLESS ( multi_hold ) %]
<form action="placerequest.pl" method="post" onsubmit="return check();" name="form"> <form action="placerequest.pl" method="post" onsubmit="return check();" name="form" id="hold-request-form">
[% ELSE %] [% ELSE %]
<form action="placerequest.pl" method="post" onsubmit="return checkMultiHold();" name="form"> <form action="placerequest.pl" method="post" onsubmit="return checkMultiHold();" name="form">
[% END %] [% END %]