How to disable button generated by submit_to_remote?

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>

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.

Both examples work, thanks.