我不知道为什么我的加载函数没有被下面的代码片段触发。直到 jqueries 加载一切正常我可以记录我传递给我的函数的数据
<script>
var oTable;
/* Formating function for row details */
function fnFormatDetails(nTr)
{
var aData = oTable.fnGetData(nTr);
$(nTr).fadeOut();
console.log(aData[1]);
container_id = aData[1];
var sOut = '<div id="edit_prod_settings_' + aData[1] + '"></div>';
return sOut;
}
$(document).ready(function() {
oTable = $('#feed_products').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../admin/?controller=products&action=getTable",
"aoColumns": [
{"sClass": "center", "bSortable": false},
null,
{sWidth: '20%'},
null,
null,
null,
null,
{"sClass": "center", "bSortable": false},
{"sClass": "center", "bSortable": false, sWidth: '5%'},
{"sClass": "center", "bSortable": false}
],
"aaSorting": [[1, 'asc']],
"fnDrawCallback": function(oSettings)
{
$('button.edit').on('click', function() {
var nTr = $(this).parents('tr')[0];
if (oTable.fnIsOpen(nTr))
{
/* This row is already open - close it */
this.src = "<button class='btn btn-warning btn-xs edit'><i class='icon-plus'></i></button>";
oTable.fnClose(nTr);
}
else
{
/* Open this row */
this.src = "<button class='btn btn-warning btn-xs edit'><i class='icon-minus'></i></button>";
//oTable.fnOpen(nTr, fnFormatDetails(nTr), 'details');
var openedRow = oTable.fnOpen(nTr, fnFormatDetails(nTr), 'details');
console.log(openedRow);
$(openedRow).each(function() {
console.log(container_id);
$('#edit_prod_settings_'+ container_id).load('../admin/?controller=products&action=getProdDetails&prod_id=' + container_id);
});
}
});
}
});
});
</script>
日志记录
console.log(aData[1]);
console.log('#edit_prod_settings_'+ aData[1]);
console.log('../admin/?controller=products& action=getProdDetails&prod_id=' + aData[1]);
回复
1402879831
#edit_prod_settings_1402879831
最后一个没有返回任何值