How to disable periodically_call_remote

I have a periodically_call_remotediv ( main_div) update in my web application. This one main_divcontains links that the user can click, causing an action that overwrites the data in main_div.

My problem is that the timer works in the function periodically_call_remote, and even if the user has moved from the page, this function call still wants to return. If present on the page main_div, a function call destroys the data that is currently displayed. If main_divnot on the page, then javascript returns an error dialog box.

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

+5
source share
2 answers

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

Essentially it comes down to overriding periodically_call_remotein a file application_helper.rbto put PeriodicalExecutorin a js variable.

You can then call poller.stop();when you want to cancel calls.

+7
source

Do you want to customize the layout / template to conditionally enable updates

-2
source

All Articles