-
-
Notifications
You must be signed in to change notification settings - Fork 710
Tips
madprops edited this page Sep 20, 2012
·
10 revisions
This is how I implement timeago in my js code:
function activate_timeago() { $('.timeago').each(function() { var $this = $(this); if ($this.data('active')!='yes') { $this.timeago().data('active','yes'); } }); setTimeout(activate_timeago, 60000); }
This iterates through every element with the timeago class and checks if it has timeago activated, if it doesn't it activates it. This checks ensures that it is not activated multiple times on the same element which can slow things down.