jquery-timeago
jquery-timeago copied to clipboard
Allow timeago to be used with jquery-livequery
livequery extends selectors to find elements "even after the page has been loaded and the DOM updated".
This patch extends timeago to be used in conjunction with livequery.
The changes are pretty simple but simply not very pretty. I'd be happy if this idea would go into timeago even in a different form.
Would like to see this pull request make it in too!
Yep me too
The included code works great, but has a performance problem. The elements array does not remove elements that are no longer visible on the page. I added the following code to remove elements that aren't visible:
$.fn.timeago = function() {
var self = this;
self.each(refresh);
// Only keep the elements that aren't hidden
var visibleElements = [];
$.each(elements, function(i, e) {
if (!$(e).is(':hidden')) {
visibleElements.push(e);
}
});
elements = visibleElements;
...
I agree. Timeago being "accurate" to the minute, it would be make sense to have dynamically added elements updated too. It would defeat timeago's purpose if this feature or some similar solution is not implemented.
+1 :/
+1 on merdjemak's comment. Hope this pull request makes it too
@cburgmer you should remove the clear
argument.
Hope this pull request gets accepted... it's a major improvement even if you don't use jquery-livequery
Me too.
+1
Hello, this was opened a long time ago (no pun intended). Is there a way today to attach timeago to live elements, without using external plugins? Is there maybe a different github issue regarding this?
I use timeago with livequery on my site like this:
$("time.timeago").livequery( ->
$(this).timeago()
)