Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Of course you can do this, but it needs some ajax magic. </p> <p>First of all, you need to create an action, responding to .js requests, in the recommendation controller. It is done so far in your update. But, your .js is not quite right. The problem is that you render the modal form from the post view, but propably in post controller you dont have the right fields. I recommend the following .js.erb:</p> <pre><code>$("#modal-body").html(&lt;%= escape_javascript render(:partial =&gt; 'recommendations/index')%&gt;); $("#my-modal").show(); </code></pre> <p>This fills the modal with the form. The next step is to do a remote request from this form. Modify your posts/index the following way:</p> <pre><code> = form_tag post_recommendations_url, :remote =&gt; true, :method =&gt; "get" do = text_field_tag :name, '', :class =&gt; "span12", :placeholder =&gt; "Please enter the name of the users you would like to share this post with." %center = submit_tag "Search", :class =&gt; "btn btn-primary" </code></pre> <p>The difference is the <code>:remote =&gt; true</code> tag, this sends an ajax request to your controller, so you must prepare for .js and .html response (in case of no JS on client). The .js should hide the modal form, and may refresh the original page, the html may redirect you back to the post.</p> <p><strong>Part 2:</strong> The problem is the :remote part. It needs to be part of the form's definition, not the submit button's. My mistake.</p> <p>I found <a href="http://www.alfajango.com/blog/rails-3-remote-links-and-forms/">this guide</a> now, it seems quite good. </p> <p>I hope it helps! Ask if something is not clear.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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