row details server side won't fire
row details server side won't fire
I try to use row details on server side but my click function doesn't gets fired inside document ready. Beacuse of obsolations of live I have been changing to .on and my codes looks as it follows
[code]$('table#feed_products.edit').on('click', '.edit', function() {
alert('test');//heres nothing
var nTr = $(this).parents('tr')[0];
if (oTable.fnIsOpen(nTr))
{
/* This row is already open - close it */
this.src = "";
oTable.fnClose(nTr);
}
else
{
/* Open this row */
this.src = "";
oTable.fnOpen(nTr, fnFormatDetails(nTr), 'details');
}
});
[/code]
[code]$('table#feed_products.edit').on('click', '.edit', function() {
alert('test');//heres nothing
var nTr = $(this).parents('tr')[0];
if (oTable.fnIsOpen(nTr))
{
/* This row is already open - close it */
this.src = "";
oTable.fnClose(nTr);
}
else
{
/* Open this row */
this.src = "";
oTable.fnOpen(nTr, fnFormatDetails(nTr), 'details');
}
});
[/code]
This discussion has been closed.
Replies
Did you try to add this function inside fnDrawCallback?
[code]
$('#dataTableMygAdv').dataTable(
{
"fnDrawCallback": function (oSettings)
{
$('table#feed_products.edit').on........
},
.
.
});
[/code]
[code]
var oTable;
/* Formating function for row details */
function fnFormatDetails(nTr)
{
var aData = oTable.fnGetData(nTr);
$(nTr).fadeOut();
console.log(aData[1]);
alert('data test');
var sOut = '';
$('#edit_prod_settings_' + aData[1] + '').load('../admin/?controller=products&action=getProdDetails&prod_id=' + aData[1]);
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)
{
$('table#feed_products.table tbody tr.odd td.center button.edit').on('click', function() {
var nTr = $(this).parents('tr')[0];
if (oTable.fnIsOpen(nTr))
{
/* This row is already open - close it */
this.src = "";
oTable.fnClose(nTr);
}
else
{
/* Open this row */
this.src = "";
oTable.fnOpen(nTr, fnFormatDetails(nTr), 'details');
}
});
}
});
});
[/code]