Loading external Jquery on datatable cell

Loading external Jquery on datatable cell

syslintsyslint Posts: 2Questions: 1Answers: 0

Hello,
My datatable as follows,

    $(function () {

        $('#list_accounts').dataTable( {
        "responsive": true,   
        "processing": true,
        "serverside": true,
        "columnDefs": [ {orderable: false, targets: [0], width: 30, targets: 0 }],
        "paging": true,
                  "lengthChange": true,
                  "searching": true,
                  "ordering": true,
                  "info": true,
                  "pageLength": 25,
                  "lengthMenu":[[25,100,200,-1],[25,100,200,"All"]],
                  "autoWidth": false,
        "ajax": {
                                "url": "ajax/schedule_user.php",

                        },
        });


    });

My table and data are loading fine .

<tr role="row" class="odd"><td class="" tabindex="0">
<input type="checkbox" class="userdata" name="user_check" value="adduser2hook">
</td><td>1</td><td><a href="http://adduser2hook.com" target="_blank">adduser2hook.com</a></td><td class="sorting_1">adduser2hook</td><td><input class="adduser2hook-input" disabled=""></td><td><div class="adduser2hook"> hi</div></td><td><a href="#" class="status_dis_account" id="adduser2hook">Disable</a></td></tr>

I am using a Jquery cron plugin in the script from https://jqcron.arnapou.net/demo/

The plugin works fine , but it won't work inside the cells after loading the table .

Cell that need to display the jquery data

<td><input class="adduser2hook-input" disabled=""></td>

I added the following jquery code on the page

$(function(){
    $('.adduser2hook-input').jqCron();
});

So this code works outside datatable. It doesn't work inside the datatable cell divs . How can I enable it.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    edited October 2020 Answer ✓

    Try placing $('.adduser2hook-input').jqCron(); inside the drawCallback function. Not all the rows are in the DOM so you probably will need to initialize for each page draw. If this doesn't help please build a test case so we can understand what you have and help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    You may need to determine if you need to disable the previous invocation to keep from building up orphaned events.

    Kevin

  • syslintsyslint Posts: 2Questions: 1Answers: 0

    Hi,

    Thank you for pointing me to the correct direction. This solved the issue.

This discussion has been closed.