Hi, I am using the update function in Prototype to periodically load new html and javascript into various elements on my page. The loaded script can include timers - I am using PeriodicalExecuter. Update works fine when it''s just replacing html - but I would like it to replace the previously loaded script as well instead of just adding the new script! I realize that this is a lot to ask for... So my question is: How can I make sure that any old script (global functions, variables and any running timers) gets cleared along with the html when I am loading the new content? Is there a neat way of doing this? Lars --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I think if you just assign each script element with a class or ID, you can later remove the element based on that ID. All the variables and functions defined will also be removed. I''ve done this before I think. On 10/18/07, happysad <larsped-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > > I am using the update function in Prototype to periodically load new > html and javascript into various elements on my page. > > The loaded script can include timers - I am using PeriodicalExecuter. > > Update works fine when it''s just replacing html - but I would like it > to replace the previously loaded script as well instead of just adding > the new script! > I realize that this is a lot to ask for... > > So my question is: How can I make sure that any old script (global > functions, variables and any running timers) gets cleared along with > the html when I am loading the new content? Is there a neat way of > doing this? > > Lars > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
That sounds almost too easy... I don''t think it''s possible. I will have to keep track of the timers, and stop them manually. Also I am going to take care that I am reusing names for functions and variables, so they are redefined when the new script is loaded. This will hopefully prevent memory leaks. On 18 Okt., 17:20, "Eric Lin" <eylinl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I think if you just assign each script element with a class or ID, you can > later remove the element based on that ID. All the variables and functions > defined will also be removed. I''ve done this before I think. > > On 10/18/07, happysad <lars...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Hi, > > > I am using the update function in Prototype to periodically load new > > html and javascript into various elements on my page. > > > The loaded script can include timers - I am using PeriodicalExecuter. > > > Update works fine when it''s just replacing html - but I would like it > > to replace the previously loaded script as well instead of just adding > > the new script! > > I realize that this is a lot to ask for... > > > So my question is: How can I make sure that any old script (global > > functions, variables and any running timers) gets cleared along with > > the html when I am loading the new content? Is there a neat way of > > doing this? > > > Lars- Skjul tekst i anførselstegn - > > - Vis tekst i anførselstegn ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
have a function that clears all the global stuff running and call that before you start new timers in the loaded html? allthough you could also bind the scripts to the container element. anyhow it is best if you think about a namespace to use cause that will make dealing with memory leaks easier. but without a peek at the code i guess pointing out directions will be a bit hard. On 19 Okt., 13:44, happysad <lars...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That sounds almost too easy... I don''t think it''s possible. > > I will have to keep track of the timers, and stop them manually. Also > I am going to take care that I am reusing names for functions and > variables, so they are redefined when the new script is loaded. This > will hopefully prevent memory leaks. > > On 18 Okt., 17:20, "Eric Lin" <eylinl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I think if you just assign each script element with a class or ID, you can > > later remove the element based on that ID. All the variables and functions > > defined will also be removed. I''ve done this before I think. > > > On 10/18/07, happysad <lars...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, > > > > I am using the update function in Prototype to periodically load new > > > html and javascript into various elements on my page. > > > > The loaded script can include timers - I am using PeriodicalExecuter. > > > > Update works fine when it''s just replacing html - but I would like it > > > to replace the previously loaded script as well instead of just adding > > > the new script! > > > I realize that this is a lot to ask for... > > > > So my question is: How can I make sure that any old script (global > > > functions, variables and any running timers) gets cleared along with > > > the html when I am loading the new content? Is there a neat way of > > > doing this? > > > > Lars- Skjul tekst i anførselstegn - > > > - Vis tekst i anførselstegn ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---