I have a page with a few buttons on it. One of them causes a file to download. That process is very server cpu intensive so I don't want them to click it twice. So I've got javascript to block a double click. The problem is I want to unblock it when the file downloads. I have a setinterval doing xmlhttp requests updating the status on the page and checking the server to see if it's done, but it seems when the file save-as popup shows up, the set interval stops running and I have no way to regain programmatic control of that page. How can I block the button and then still have control to unblock it later?
views:
93answers:
1
+1
A:
Just use the input.disabled
property. It'll look something like this:
var btn = $('my_button');
btn.observe('click', function(){
this.disabled = true;
Ajax.Request(some_url, {
onSuccess:btn.disabled = false;
})
}
I'm using Prototype there but it should readable enough to be easily translated to any other library.
Triptych
2009-08-05 15:13:03