[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: Any success with storing photos in a database? (prevents double-submits)
From:       Eric Howe <eric () pieinsky ! ca>
Date:       2008-10-16 3:45:58
Message-ID: AB010EF5-019B-402F-8658-2B0CF00A917A () pieinsky ! ca
[Download RAW message or body]

On Oct 15, 2008, at 11:11, Cosimo Streppone wrote:

> On Wed, Oct 15, 2008 at 12:31 PM, Mark wrote:
[...]
> Then Perrin wrote:
>
>> JavaScript is okay, but can be a problem when people hit back
>> expecting to use the form again and the button is still disabled.
>
> You could always trigger some javascript event on page load
> the re-enables the submit control, even if already enabled,
> resetting the flag to "0". This is what I did.

I do it this way (via jQuery) and it works okay even when faced with  
the browser's back-button:

	function returnFalse() {
	        return false;
	}
	$(document).ready(function() {
	        // Take care of back-button issues first.
         	$('form').find(':submit').unbind('click', returnFalse);
         	// Then wire up the auto-disabling stuff.
         	$('form').submit(function() {
         	        $(this).find(':submit').click(returnFalse);
         	        return true;
         	});
	});

I don't use the 'disabled' attribute as that prevents the browser (at  
least some of them) from sending the button back to the server with  
the rest of the form.

Eric Howe
eric@pieinsky.ca

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic