With form_tag submit buttons I use the " :disable_with => ‘button label
while processing’ " option so that visitors with slow connections
aren’t able to submit forms twice.
How do I do the same thing with button_to?
I’ve got several pages where there are multiple forms on the page being
updated with Ajax so I can’t wrap the whole thing with a form_tag, and I
can’t get button_to to take a :disable_with option.
What does your ‘button_to’ call look like?
You should be able to associate a JS function with the control so that
it will disable the button when it is clicked.
On Monday, July 24, 2006, at 2:16 PM, Bill W. wrote:
With form_tag submit buttons I use the " :disable_with => ‘button
label while processing’ " option so that visitors with slow
connections aren’t able to submit forms twice.
How do I do the same thing with button_to?
What does your ‘button_to’ call look like?
You should be able to associate a JS function with the control so that
it will disable the button when it is clicked.
As usual, it turns our Rails makes it even easier than that When I
looked at the documentation for the two I realized they took the same
arguments. Well… except that form_tag takes the :disable_with option
and
button_to doesn’t. So I just substituted an empty form with the submit
button styled the same way I had the button_to styled.
NOTE: This works fine in the situation I was in, where the button_to
was
simply taking the visitor to another page. I do have one situation
where
there are three buttons on the page, two of which do something but
currently
have render => :nothing in the controller, so I’m sure I’ll have to go
to
something like your suggestion to get one of those two buttons to
refresh
when the controller action is done. The other doesn’t need to be
refreshed.
Or maybe I just change the page a bit so I can use the above.
Thanks for your response, though!
Best regards,
Bill
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.