Support unloading timeago elements. fixes #40 #90

Open
wants to merge 1 commit into
from

Projects

None yet

5 participants

@dshafer
dshafer commented Sep 7, 2012

Adds explicit untimeago() function that removes all timeago timers and data.
Hooks jQuery.events.special.remove to automatically call untimeago() when elements are removed from the DOM

Note, this does not handle automatically removing timeago timers if the DOM elements are removed by some means other than $().remove()

My earlier commit on issue 40 had a bug when calling untimeago() on non-timeago elements. This single commit includes the untimeago implementation with the fix for that bug (i.e. the earlier commit should be disregarded)

@dshafer dshafer Support unloading timeago elements
Adds explicit untimeago() function that removes all timeago timers and
data.
Hooks jQuery.events.special.remove to automatically call untimeago()
Note, this does not handle automatically removing timeago timers if the
DOM elements are removed by some means other than $().remove()
d7259a7
zakjan commented Oct 5, 2012

This fix is working, thank you.

Useful Commit. Would like to see this in timeago.

@mweibel mweibel pushed a commit to mila-labs/jquery-timeago that referenced this pull request Mar 28, 2013
Michael Weibel Implemented only one Interval on a page.
This commit will fix jquery.timeago's issue to have an interval
for each timeago element on a page.
By doing this it also removes destroyed elements automatically.

As such, this commit fixes rmm5t/jquery-timeago#96 and
rmm5t/jquery-timeago#90.
7891957
Owner
rmm5t commented Oct 2, 2013

I'm sorry for not keeping up with this project lately. I like the idea behind this PR, but it needs some rebasing first.

The core codebase has changed a bit, and it would probably be better to use our new functions convention instead of instead of $.fn.untimeago. Something like $(…).timeago("remove"). I'm not sure what the function name should be, but maybe there's good precedence out there for this kind of thing.

Brainstorming:

  • $(…).timeago("remove")
  • $(…).timeago("delete")
  • $(…).timeago("off")
  • $(…).timeago("unload")
philfreo commented Oct 2, 2013

remove is probably the best name (matches jQuery's $.remove functionality) if it turns off the timeago functionality and fully cleans up everything.

You should also look at #30 - that's been helpful for us in dealing with leaks. The idea is that you should be able to call timeago() multiple times on the page (perhaps each time you add to the DOM) without having to worry about cleaning up the previous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment