These 2 versions will disable the button:

<%= submit_to_remote "add", "Add", :url => { :action =>
"add_groups" }, :html => {:update => 'divgrouptable', :disabled =>
true} %>
<%= submit_to_remote "add", "Add", :url => { :action =>
"add_groups" }, :update => 'divgrouptable', :html => {:disabled =>
true} %>

I have never used the submit_to_remote before and I'm not too familiar
with the Ajax helpers so I'm not sure if :update has to be inside
the :html hash or not. In any case, in the docs the example reads like
this:

:update => { :success => "succeed", :failure => "fail" }

I don't know if your :update stuff will work as it is.

On Aug 20, 5:36 pm, Tomasz Romanowski <[email protected]> wrote:
> I got a submit_to_remote button that I'd like to show as disabled on a
> certain condition. I'd assume the usual :disabled => true would do but I
> have not been able to. Comparing page source shows that for example:
>
> <%= submit_to_remote "add", "Add", :url => { :action => "add_groups" },
> :update => 'divgrouptable', :disabled => true %>
>
> the ":disabled = true" statement has no effect on the generated html.
> Also tried "{ :disabled => true }" and a few others.
>
> I went as far as writing on-load hook and disabling the buttons in the
> java script as shown below but sounds like a lot of effort to achieve
> this. How could I make this less "obtrusive"?
>
> function disable_buttons()
> {
> <% if @readonly %>
>    document.getElementsByName('add')[0].disabled = 1
>    document.getElementsByName('remove')[0].disabled = 1
> <% end %>
>
> }
>
> </script>
>
> <body onload="javascript:onloadd()">
>
>  <original form goes here.......>
>
> </body>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to