javascriptphpdatatabletimeago

timeago.js with datatable and PHP


I am displaying data of dates in my datatable using timeago.js along with the use of PHP. The problem is some data specifically dates in my datatables are missing when I click on the next page of my datatable. I don't know how to fix this, please help.

This is my Datatable-Table on its first page

Date_Joined        Username
8 minutes ago       john
10 minutes ago      jake
20 minutes ago      jay

And this is the next page of my datatable showing no date

Date_Joined        Username
                     may
                     june
                     april 

and if i click on my datatable to view 10, 25, 50, 100 pages

Date_Joined        Username
8 minutes ago       john
10 minutes ago      jake
20 minutes ago      jay
                    may
                    june
                    april

Please I really need your help.


Solution

  • Add this code inside your tag. It should work when you click the next page.

    inside $("") add the table id and add _paginate next to it

    $("#simpledatatable_paginate").click(function(){
                jQuery("abbr.timeago").timeago();
        });
    

    While the above code works only for the pagination. This code here will allow you to solve your problem. Replace the above code with this code:

    $("#simpledatatable").on('draw.dt', function(){ jQuery("abbr.timeago").timeago(); });

    add this code before you iniatilize your datatable.