I have a simlple view:
<h2>Tags</h2> <% unless @recipe.tags.empty? %> <table> <tbody id="tags"> <%= render :partial=>'tags/tag', :collection=>@recipe.tags %> </tbody> </table> <% end %> <% form_remote_tag :url=>tags_path(@recipe) do%> <label>Name</label> <%= text_field_with_auto_complete :tag, :name %> <%= submit_tag "Add Tag" %> <% end %>
Which has a pretty simple create method that renders the RJS as follows:
format.js { render :update do |page| page.insert_html :bottom, 'tags', :partial=>'tags/tag' end }
The problem is that no insertion happens. Under IE I get an RJS alert, under FF I get nothing. Firebug reports that the POST request is successful and has the has the correct results:
try { new Insertion.Bottom("tags", "<tr>\n <td>Please Work</td>\n <td><a href=\"/recipes/6/tags/28;edit\">Edit</a></td>\n <td><a href=\"/recipes/6/tags/28\" onclick=\"if (confirm('Are you sure?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;\">Delete</a></td>\n</tr>\n"); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('new Insertion.Bottom(\"tags\", \"<tr>\\n <td>Please Work</td>\\n <td><a href=\\\"/recipes/6/tags/28;edit\\\">Edit</a></td>\\n <td><a href=\\\"/recipes/6/tags/28\\\" onclick=\\\"if (confirm(\'Are you sure?\')) { var f = document.createElement(\'form\'); f.style.display = \'none\'; this.parentNode.appendChild(f); f.method = \'POST\'; f.action = this.href;var m = document.createElement(\'input\'); m.setAttribute(\'type\', \'hidden\'); m.setAttribute(\'name\', \'_method\'); m.setAttribute(\'value\', \'delete\'); f.appendChild(m);f.submit(); };return false;\\\">Delete</a></td>\\n</tr>\\n\");\n'); throw e }
I threw the above JS into a test page and it works successfully, but for some reason it is not working through the form. Again, in IE the error is thrown, and in Fire Fox nothing is happenning at all. No warnings or errors are thrown.
Anyone have any ideas on what I am doing wrong?
Thanks, Dan