jquery-timeago
jquery-timeago copied to clipboard
Support unloading timeago elements. fixes #40
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)
This fix is working, thank you.
Useful Commit. Would like to see this in timeago.
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")
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.