Search code examples
ruby-on-railsrubyajaxprototypejs

Prototype, periodically_call_remote, updated content disappears when new link is clicked and lags


periodically_call_remote is a great rails feature, but with ease comes novices so here I am.

I have a div that is getting updated with content every 5 seconds. Looks great and was easy to setup. This page is the homepage so people will not be staying here long. So when they click another link, such as link_to "All Products", periodically_call_remote creates two displeasing issues.

1) For one thing, periodically_call_remote doesn't stop when a html link is clicked and I believe that this is causing the lag in response to open the selected page.

2) Also, when an html link is clicked the content inside the updated div disappears.

Any conceptual solutions?


Solution

  • This only occurred in FF because I had a div inside the updating div which had my content and that middle div had no purpose.

    For example.

    <div id="main_div">  
       <div class="div_with_no_purpose">  <<=== problem div
           <div id="div_getting_updated">  <<=== content goes here
           </div>
       </div>  
    </div>