Welcome Guest, Not a member yet? Register   Sign In
Prototype: Ajax.PeriodicalUpdater keeps running after container is removed or changed
#1

[eluser]Nonox[/eluser]
Hi there, I have a question about Ajax.PeriodicalUpdater,

I hope don't bother nobody.

If you use PeriodicalUpdater to return data to fill a component, such as a DIV, and that div is then deleted or changed, the PeriodicalUpdater continues to run, How can I solve this? I have been searching in net, but I can't get the solution.

Thank!
NB.
#2

[eluser]Mike Ryan[/eluser]
Hi,

PeriodicalUpdater has a 'stop' method, which will prevent it from running.
#3

[eluser]Nonox[/eluser]
Yes is true, the "stop" method works fine before the reload the div container, the problem if after reload the div container, the PeriodicalUpdater continuous running.
#4

[eluser]Mike Ryan[/eluser]
That would suggest it is being stopped and then restarted. Maybe you could check (on reload) to see if PeriodicalUpdater should be started again?

Is the Updater code stored within the div that gets reloaded? If so, moving it out of that div should help, as it won't get restarted on reload.
#5

[eluser]Nonox[/eluser]
My code looks in that way:


Code:
<div id='dropdown'>
<select name="category"><option></option></select>
</div>
When the select change the DIV container is reload.

Code:
<div id='container'>
The page load here has the PeriodicalUpdater
</div>
The code load here works fine, and stop when some part of the code in the success function is triggered, the issue is presented if I change the dropdown before the stop method is called, the div is reload with another page and the PeriodicalUpdater charged before is still running.


I hope to be clear, this is driving me crazy!
NB.
#6

[eluser]Mike Ryan[/eluser]
How about calling the stop function immediately after the item in the dropdown box is selected? That should stop the 'old' PeriodicalUpdater before the 'new' one starts.
#7

[eluser]Nonox[/eluser]
Well, I tried and didn't work, but even if that work fine, I think is a dirty way, imagine if my select has ten diferents options and all of this load diferent PeriodicalUpdater, I should always stop all the PeriodicalUpdater in ten diferents ways ?
#8

[eluser]Mike Ryan[/eluser]
If it doesn't work it's a moot point, but I would just do it once in the 'selected/clicked' function for the dropdown rather than once for each item.

Have I understood the problem correctly - you want the PU to stop after you select the item in the dropdown right?
#9

[eluser]Nonox[/eluser]
Yes this is the issue, I'm going to try with the observe function in the div, in the select, And calling the stop function immediately after the item in the dropdown box is selected like you said.




Theme © iAndrew 2016 - Forum software by © MyBB