Loading external Jquery on datatable cell
Loading external Jquery on datatable cell
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
Try placing
$('.adduser2hook-input').jqCron();
inside thedrawCallback
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
Hi,
Thank you for pointing me to the correct direction. This solved the issue.