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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With