making new rows selectable

making new rows selectable

barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
edited November 2012 in General
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]

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Use `on` just once:

    [code]
    $('#example tbody').on('click', 'td', function () {
    ...
    } );
    [/code]

    Allan
  • barrykeepencebarrykeepence Posts: 22Questions: 0Answers: 0
    Blimey (as we say round here) that was fast

    I changed 'td' for 'tr' and it worked a treat

    Thank you - reet braw (not a typo - scots)
This discussion has been closed.