Note that there are some explanatory texts on larger screens.

plurals
  1. POform_remote_for not executing RJS, just displays JS
    primarykey
    data
    text
    <p>I'm using prototype/rjs on rails 2.3.3 and ruby 1.86 and my <code>form_remote_for</code> to my "create" controller just displays the create.js.rjs instead of executing it. The strange this is that all the other action+rjs's work fine, just the "create" action isn't working Any help would be appreciated. Thanks in advance!</p> <p>UPDATE: To clarify, it should work: _form submit -> POST -> create method -> js -> load different partial. Instead it is working: _form submit -> POST -> create method -> outputting js as text</p> <p>_form.html.haml:</p> <pre><code>- form_remote_for(@network) do |f| = f.error_messages %p&gt;&lt; = f.label :name = f.text_field :name %p&gt;&lt; = f.label :image_url = f.text_field :image_url %p&gt;&lt; = f.label :url = f.text_field :url %p&gt;&lt; = f.submit "Create" </code></pre> <p>create.js.rjs:</p> <pre><code>page.insert_html(:bottom, :networks, :partial =&gt; 'networks/network', :object =&gt; @network); </code></pre> <p>networks_controller:</p> <pre><code>def create @network = Network.new(params[:network]) respond_to do |format| if @network.save flash[:notice] = 'Network was successfully created.' format.js #also doesn't work with { render :layout =&gt; false } else format.html { render :action =&gt; "new" } format.xml { render :xml =&gt; @network.errors, :status =&gt; :unprocessable_entity } format.js end end end </code></pre> <p>output (it displays as html):</p> <pre><code>try { Element.insert("networks", { bottom: "&lt;div class='network'&gt;\n &lt;img alt=\"Df\" src=\"/images/df\" /&gt;\n &lt;a href=\"d\"&gt;wer&lt;/a&gt;\n &lt;a href=\"/networks/39\"&gt;Show&lt;/a&gt;\n &lt;a href=\"/networks/39/edit\"&gt;Edit&lt;/a&gt;\n &lt;a href=\"/networks/39\" 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);var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'dfleb/EzulRpXnZekVfbhAkX3G9jHmhnWTBLSk7iRSE='); f.appendChild(s);f.submit(); };return false;\"&gt;Destroy&lt;/a&gt;\n&lt;/div&gt;\n" }); } catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.insert(\"networks\", { bottom: \"&lt;div class=\'network\'&gt;\\n &lt;img alt=\\\"Df\\\" src=\\\"/images/df\\\" /&gt;\\n &lt;a href=\\\"d\\\"&gt;wer&lt;/a&gt;\\n &lt;a href=\\\"/networks/39\\\"&gt;Show&lt;/a&gt;\\n &lt;a href=\\\"/networks/39/edit\\\"&gt;Edit&lt;/a&gt;\\n &lt;a href=\\\"/networks/39\\\" 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);var s = document.createElement(\'input\'); s.setAttribute(\'type\', \'hidden\'); s.setAttribute(\'name\', \'authenticity_token\'); s.setAttribute(\'value\', \'dfleb/EzulRpXnZekVfbhAkX3G9jHmhnWTBLSk7iRSE=\'); f.appendChild(s);f.submit(); };return false;\\\"&gt;Destroy&lt;/a&gt;\\n&lt;/div&gt;\\n\" });'); throw e } </code></pre> <p>Update:</p> <p>_networks.html.haml:</p> <pre><code>%div{:id=&gt; 'network#{network.id}', :name =&gt; 'network'} = image_tag network.image_url = link_to network.name, network.url - if logged_in? &amp;&amp; self.current_user.login = "admin" = link_to 'Show', network = link_to 'Edit', network_path(network), :method =&gt; :put, :class =&gt; "put" = link_to 'Destroy', network_path(network), :method =&gt; :delete, :class =&gt; "delete" %br </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload