Rails: Ajax: Changes Onload -


i have web layout of looks this

<html>   <head>   </head>    <body>     <div id="posts">       <div id="post1" class="post" >          <!--stuff 1-->       </div>       <div id="post2" class="post" >          <!--stuff 1-->       </div>        <!-- 96 more posts -->        <div id="post99" class="post" >          <!--stuff 1-->       </div>     </div>              </body> </html> 

i able load , render page blank , , have function called when page loaded goes in , load posts , updates page dynamically.

in rails, tried using "link_to_remote" update of elements. tweaked posts controller render collection of posts if ajax request (request.xhr?). worked fine , fast. update of blank div triggered clicking link. same action happen when page loaded don't have put in link.

is there rails ajax helper or rjs function or in rails use trigger loading of "posts" after page has loaded , rendered (without posts)?

(if putsch comes shove, copy generated js code link_to_remote call , have called onload handler on body).

sure there is, it's rails, after :)

something do:

<% javascript_tag %>   $(document).ready(function() {     <%= remote_function(:update => "posts", :url => posts_partial_path) %>   }); <% end %>  

remote_function give same javascript gets executed when use rails ajax helpers.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -