I’ve looked at this before and found javascript that works for me with Google Chrome, Firefox, and IE when I test it but it seems randomly (or browser specific) it doesn’t work. I need a solution that does work.
This is what I’m currently using with jQuery:
$(document).ready(function () {
$("a.Once").one("click", function () {
$(this).click(function () { return false; });
});
});
I add the class “Once” to buttons I want to make sure aren’t clicked more than once. Again, It always works properly for me but for some users it doesn’t do anything at all. Is there a better alternative solution that always works?
Update: These are ASP.NET LinkButtons.
Update 6/18:
I’ve gotten more info from two users who keeps having this problem.
One says he hits the button once and the screen flashes so he leaves the page and comes back to it and hits the button again which causes it to post twice automatically.
The other claims he hits a different button which causes this button to postback twice automatically. I looked at the code and there’s nothing wrong with that button.
The only thing I can think of is a caching problem or maybe hitting the button before the page finishes loading. I haven’t been able to reproduce the problem and one of them is using the exact same browser I use.
If this is for a form post, then you can disable all submit buttons on submit with:
Or are they allowed to click more than once, but only after some time has elapsed?
There are scenarios where one() fails – see the comments on
http://api.jquery.com/one/
Any idea if its a browser compat issue with your users or jQuery not loading?
EDIT:
Just found out this is a linkbutton. in that case try
or using the clientid directly something like