Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unloading timeago elements. fixes #40 #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dshafer
Copy link

@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)

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()
@zakjan
Copy link

zakjan commented Oct 5, 2012

This fix is working, thank you.

@bhargavgolla
Copy link

Useful Commit. Would like to see this in timeago.

mweibel pushed a commit to mila-labs/jquery-timeago that referenced this pull request Mar 28, 2013
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#96 and
rmm5t#90.
@rmm5t
Copy link
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
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants