add new row and set img click event on one column of newly created row
add new row and set img click event on one column of newly created row
![manoharsolanki123](https://secure.gravatar.com/avatar/4b53818298a46d0ba66460c949122e8e/?default=https%3A%2F%2Fvanillicon.com%2F4b53818298a46d0ba66460c949122e8e_200.png&rating=g&size=120)
Hi Allan,
I need to add a new row to a datatable which I have achieved using fnAddData()
Now on this row I have a image which on clicked supposed to opens a dialog box.
I have this click function working for existing rows, but when a new row is added this click event is not working.
Not sure but I suppose its a post initialisation event, so I saw the tooltip eg on your site.
But my confusion is that what do I use $( oTable.fnGetNodes() ).XXXXX here
Thanks in advance
code is below:
[code]
$(document).ready(function() {
oTable = $('#addModifySuppTbl').dataTable();
$('#add').click( function() {
$('#addModifySuppTbl').dataTable().fnAddData( [
"",
"",
"",
"",
"",
""
],true );
giCount++;
});
$('td img', oTable.fnGetNodes() ).each( function () {
$(this).click( function () {
var rowIndex = this.parentNode.parentNode.rowIndex;
/* Get the position of the current data from the node */
var aPos = $('#addModifySuppTbl').dataTable().fnGetPosition( this );
//Opens a dialog for that row
$('#searchDialog').data("rowIndex",rowIndex).dialog('open');
} );
} );
});
[/code]
regards,
Manohar
I need to add a new row to a datatable which I have achieved using fnAddData()
Now on this row I have a image which on clicked supposed to opens a dialog box.
I have this click function working for existing rows, but when a new row is added this click event is not working.
Not sure but I suppose its a post initialisation event, so I saw the tooltip eg on your site.
But my confusion is that what do I use $( oTable.fnGetNodes() ).XXXXX here
Thanks in advance
code is below:
[code]
$(document).ready(function() {
oTable = $('#addModifySuppTbl').dataTable();
$('#add').click( function() {
$('#addModifySuppTbl').dataTable().fnAddData( [
"",
"",
"",
"",
"",
""
],true );
giCount++;
});
$('td img', oTable.fnGetNodes() ).each( function () {
$(this).click( function () {
var rowIndex = this.parentNode.parentNode.rowIndex;
/* Get the position of the current data from the node */
var aPos = $('#addModifySuppTbl').dataTable().fnGetPosition( this );
//Opens a dialog for that row
$('#searchDialog').data("rowIndex",rowIndex).dialog('open');
} );
} );
});
[/code]
regards,
Manohar
This discussion has been closed.
Replies
Allan
It does worked.
Regards,
Manohar
It solves me the same question
Ray