making new rows selectable
making new rows selectable
barrykeepence
Posts: 22Questions: 0Answers: 0
I am adding rows dynamically and using a great snippet from this site to make then editable. I have tried to use the same code to add a click handler to make them selectable but it does not work. How come it works for editable and not for selectable?
Here is the code:
[code]
var aiData = oTable.fnAddData ( oRoom );
var oSettings = oTable.fnSettings();
// this bit works
$('td', oSettings.aoData[ aiData[0] ].nTr).editable(function(value, settings) {
var aPos = oTable.fnGetPosition( this );
console.log (aPos);
return(value); }, {
type : 'text',
event : 'dblclick',
} );
// the same selector with the click bind does not work - even with td replaced by tr
$('td', oSettings.aoData[ aiData[0] ].nTr).click(function(value, settings) {
// my func
} );
[/code]
Here is the code:
[code]
var aiData = oTable.fnAddData ( oRoom );
var oSettings = oTable.fnSettings();
// this bit works
$('td', oSettings.aoData[ aiData[0] ].nTr).editable(function(value, settings) {
var aPos = oTable.fnGetPosition( this );
console.log (aPos);
return(value); }, {
type : 'text',
event : 'dblclick',
} );
// the same selector with the click bind does not work - even with td replaced by tr
$('td', oSettings.aoData[ aiData[0] ].nTr).click(function(value, settings) {
// my func
} );
[/code]
This discussion has been closed.
Replies
[code]
$('#example tbody').on('click', 'td', function () {
...
} );
[/code]
Allan
I changed 'td' for 'tr' and it worked a treat
Thank you - reet braw (not a typo - scots)