Reloading partial in an rails app

I want to reload a partial every 3 seconds on a 'new'-view in my rails app.

I have this in my new.html.erb

This is my static content
<%= render partial: 'dynamic' %>
More Static content

How do I get this partial reloaded every 3 seconds? Do I have to use unobtrusive javascript for this? How can I achieve this through ujs?



Put partial in div

   <div class="dynamic"><%= render partial: 'dynamic' %></div>

You can do it by using jquery like this

         function() {
          setInterval(function() {
        }, 3000);

Now refresh partial in controller action for load new content

         def action_name
            render :partial => "directory_name/dynamic"

It will sure work.........


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.