jquery-timeago icon indicating copy to clipboard operation
jquery-timeago copied to clipboard

Allow timeago to be used with jquery-livequery

Open cburgmer opened this issue 14 years ago • 11 comments

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.

cburgmer avatar Jan 25 '11 15:01 cburgmer

Would like to see this pull request make it in too!

zackchandler avatar Mar 25 '11 16:03 zackchandler

Yep me too

kaareal avatar May 24 '11 14:05 kaareal

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;
    ...

mutewinter avatar Jul 26 '11 13:07 mutewinter

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.

merdjemak avatar Nov 16 '11 16:11 merdjemak

+1 :/

diegorv avatar Mar 27 '12 18:03 diegorv

+1 on merdjemak's comment. Hope this pull request makes it too

shichan avatar Mar 30 '12 09:03 shichan

@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

philfreo avatar Jul 07 '12 04:07 philfreo

Me too.

dgilperez avatar Nov 13 '12 11:11 dgilperez

+1

bobartlett avatar Jul 19 '13 21:07 bobartlett

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?

NathanHazout avatar Feb 11 '14 17:02 NathanHazout

I use timeago with livequery on my site like this:

   $("time.timeago").livequery( ->
        $(this).timeago()
    )

chalkup avatar Feb 11 '14 19:02 chalkup