[英]DataTable jquery selectors not firing
I have following code to handle clicks on row or individual cells. 我有以下代码来处理对行或单个单元格的单击。
$(document).ready(function() {
var JSON_URL = '{% url "technician_activity" %}';
var oTable = $('#technician_activity').dataTable( {
"processing": true,
"serverSide": true,
"ajax": JSON_URL ,
"jQueryUI": true
} );
alert("Without this alert selectors don't work? oTable = " + oTable);
oTable.$('tr').click( function () {
var data = oTable.fnGetData( this );
alert("Column " + data);
});
oTable.$('td').click( function () {
var data = oTable.fnGetData( this );
alert("Cell " + data);
});
});
One thing that puzzels me is without the first alert statement 令我感到困惑的是,没有第一个警报声明
alert("Without this alert selectors don't work? oTable = " + oTable);
selectors for tr and td don't work this is very puzzling to me -- what is the difference that this alert() is making? tr和td的选择器不起作用,这让我很困惑-这个alert()有什么区别?
I am now using code as suggested here - http://www.datatables.net/examples/server_side/select_rows.html 我现在正在使用此处建议的代码-http: //www.datatables.net/examples/server_side/select_rows.html
But it still remains question as to why the in code I initially posted, with first alert() statement things work but they don't work when that alert statement is absent.... 但是对于为什么我最初发布的in代码中的第一个alert()语句仍然起作用,但在缺少该Alert语句时它们却不起作用,仍然存在疑问。
Just for curiosity sake would like to understand whats going on there in case someone has ideas. 出于好奇,我想了解发生了什么事,以防有人提出想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.