I am attempting to capture row selection via a (DataTable) TableTools button's fnSelect() (to do some pre-processing of the row's data) ie. the user selects a row, some manipulation of the row data is done; then user can click the button.
Problem is that the event (ie selecting the row) appears to fire twice -- the console.log()
is clearly output twice...
And I've tried this using various versions of jQuery but always with the same result.
My table's definition is as follows:
$('#example').DataTable( {
dom: 'T<"clear">lfrtip',
tableTools: {
"sRowSelect": "single",
"aButtons": [
{
sExtends:"text",
sNewLine: "<br/>",
sButtonText: "edit",
fnSelect: function(nButton, oConfig, nRow){
// replicates the behaviour of the select_single button
// ie disable button unless a row is selected
var iSelected = this.fnGetSelected().length;
if ( iSelected == 1 ) {
$(nButton).removeClass( this.classes.buttons.disabled );
} else {
$(nButton).addClass( this.classes.buttons.disabled );
}
// "do something" is output twice.
console.log("[edit button's fnSelect()] do something");
// so this would be a problem...
// row_data = this.fnGetSelectedData()[0]);
// do some function(row_data){}
},
},
],
}
});
And I have a jsfiddle demonstrating this problem/behaviour.
I'd be grateful if anyone could shed some light on what I'm doing wrong (before I yell 'bug'!!)
Many thanks.