Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The easiest/fastest way to do this is to create some new controller actions with html.erb templates, then to use jquery's load() function. So:</p> <p>First, create a new action that outputs (using an .html.erb template) the HTML you want to display after documentReady. Make sure that your controller doesn't use layouts for the action, and create a named route that links to the action. Since you've already got the helper functions written, the template should just call your helper function with the appropriate arguments.</p> <p>So, if your controller is called 'Users', and your new action is called 'ajax_info', you would create a new route called user_ajax_info, and link it into 'users/ajax/info'. If you went to user/ajax/info in the browser, you'd see the content (and only the content) you wanted to plug into your document using AJAX.</p> <p>You can then load the content on document ready using Jquery's load(), eg:</p> <pre><code>&lt;%= javascript_tag do %&gt; $(document).ready(function() { $('spinner1').load('&lt;%= user_ajax_info_url -%&gt;'); }); &lt;% end %&gt; </code></pre> <p>Rails will then automatically pass the correct URL for user_ajax_info to Jquery; Jquery will load the content at that URL, and replace the content of spinner1 with the new content. See <a href="http://api.jquery.com/load/" rel="nofollow">http://api.jquery.com/load/</a> for more details.</p> <p>Note that technically, this is probably not best practice; it would be a lot better (from a practices point of view) to return the data using XML/JSON. On the other hand, that's also a lot trickier to implement; I'd recommend starting with this, and then updating later if it becomes necessary. </p>
    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. 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.
    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