On Mar 24, 8:04 pm, "Kjell Bublitz"
<m3nt0r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I have a tricky question. Would be possible to attach a timeout to an
> element so if the element is gone, the timeout is gone too ? Or to
> create somewhat of a direct relation in some pseudo object oriented
> fashion?
setTimeout returns a reference that can be used with clearTimeout to
cancel the the timeout. When you set the timeout, store the reference
somwhere. If you remove the element, check if there''s a timeout
related to it and if so, cancel it.
I''m not sure there''s any point in doing so, the extra overhead
of
managing the timeouts may well exceed any benefit of removing them
early.
> I am really trying hard to figure out a good way to manage multiple
> timed events, but i couldn''t find a solution which seems reliable
> enough. Maybe there is something i have overlooked.
The simplest method is to check that the element exists when the
function runs. If not, do nothing.
--
Rob
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---