Jquery datatable and cakePHP

I am trying to implement jquery datatable on my cakePHP based website, but it just won't load. this website is already half developed, and, as I see it, js' is loaded through a file with a name _head.inc.ctplocated inside the folder views/layouts, I added the datatables library inside the libs folder, which you webroot/js/libsupload to the file _head.inc.ctp.

suppose I have this: my controller:

var $helpers = array(
    'Form',
    'Html',
    'Javascript'
);
//my method
function dataTable_example($id=null){
    $details = $this->Detail->find("all");
    $this->set('details', $details );
}

my opinion:

<div>
    <?php echo $javascript->link('libs/jquery.dataTables.js'); ?>
<script>
    $(document).ready(function(){
        $('#js-datatable').dataTable();
    });
</script>
    <h2><?php echo __l('Tickets');?></h2>
    <div>
        <table id="js-datatable">
            <tr>
                <th>some heading 1</th>
                <th>some heading 1</th>
                <th>some heading 1</th>
            </tr>
            <?php
            if (!empty($details)){
                foreach ($details as $detail):
            ?>
            <tr>
                <td><?php echo $detail['Detail']['id'];?></td>
                <td><?php echo $detail['Detail']['created'];?></td>
                <td><?php echo $detail['Detail']['ticket_detail'];?></td>
            </tr>
            <?php
                endforeach;
            }else{
            ?>
            <tr>
                <td>No Data Found</td>
            </tr>
            <?php }?>
        </table>
    </div>
</div>

I even hard-coded it using a regular call and checked it with firebug to see if the script is loaded or not, and according to firebug it is loaded, so I can’t understand what the script does to fail my table.

Did I skip a few steps? please, help

thank

+5
2

thead tbody datatables script

+3

find ..

+1

All Articles