-
-
Notifications
You must be signed in to change notification settings - Fork 708
Tips
Edho Arief edited this page Sep 10, 2015
·
10 revisions
This is how I implement timeago in my JavaScript 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 check ensures that it is not activated multiple times on the same element, which can slow things down.
Alternatively:
$('.timeago-new').timeago().removeClass('timeago-new')