Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off "periodically_call_remote"

Tags:

I have periodically_call_remote updating a div (main_div) in my web app. This main_div contains links that the user can click that invokes an action that overwrites data within main_div.

My problem is that the timer is running on the periodically_call_remote function and even though the user has navigated away from the page, that function call still wants to return. If the main_div is present on the page the function call wipes out the data that was currently being displayed. If the main_div is not on the page then the javascript returns an error dialog.

So, my question is, when the user navigates away from the div that is periodically being updated, how do I stop the function call?

like image 709
salt.racer Avatar asked Dec 19 '08 00:12

salt.racer


1 Answers

This thread: http://www.ruby-forum.com/topic/119372 provided the answer that I needed.

Essentially it boils down to overriding periodically_call_remote in the application_helper.rb file to put the PeriodicalExecutor into a js variable.

Then, you can call poller.stop(); whenever you want to cancel the calls.

like image 135
salt.racer Avatar answered Sep 30 '22 19:09

salt.racer