Ignore :update in for example submit_to_remote!
I am now extremely tired on bad documentation. And documentation and hints that just reprint what was in the first documentation. It seems some code has not been used by anyone. Or, everyone write exactly the same code!
In my case I had problems with form_remote_to and later submit_to_remote. If there was a :update argument to the submit_to_remote, the javascript code was inserted in the DOM object the :update referred to.
I was using the great Firebug plugin for firefox to debug the actual AJAX requests. My first thinking was that the content-type header in the response was wrong so that the Prototype library did not interpret the javascript. But, that was not it.
At last, in this post I started to get some ideas on what was going on. The first real example for how to use submit_to_remote. The solution was to not include any :update item in the hash.
Here is some code that works, first the new.rhtml view:
<form id="theForm">
<table>
<tr id="adminc">
<td align="right"><B>Adminc:</B></td>
<td><%= text\_field 'regrequest', 'adminc' %></td>
</tr>
</table>
</form>
<%= submit\_to\_remote "create-button", "Create",
:url => { :action => "create" },
:submit => "theForm" %>
Then the controller (create):
def create
render :update do |page|
page[:adminc].toggle
end
end