我使用带有隐藏行的DataTables插件,在使用分页时,单击事件失败而不会出现控制台错误。
这是一项功能:
$(document).ready(function() {
$('#datatable tbody td a').on('click', function (e) {
e.preventDefault();
var nTr = $(this).parents('tr')[0];
if ( oTable.fnIsOpen(nTr) ) {
/* This row is already open - close it */
$(this).addClass('glyphicon-arrow-down');
$(this).removeClass('glyphicon-arrow-up');
oTable.fnClose( nTr );
} else {
/* Open this row */
$(this).addClass('glyphicon-arrow-up');
$(this).removeClass('glyphicon-arrow-down');
oTable.fnOpen( nTr, fnFormatDetails(oTable, nTr), 'details' );
}
});
});正如您所看到的,我正在使用委托,但是函数被包装在一个现成的函数中。我肯定这就是问题所在。我该怎么解决这个问题?
上面的问题是错误的,请看我在答案下面的评论。
https://stackoverflow.com/questions/19609085
复制相似问题