Very new to JQuery, I have a data table integrated in my application. I have added two buttons in the last column, but facing issues with binding it with particular event.
Here is my code to generate last column of the table.
"mRender": function (data, type, full) {
console.log('>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<');
console.log(full);
if(full.status) {
return '<button href="#"' + 'id="'+ data + '">Edit</button> <input type="button" href="#"' + 'id="disable-'+ data + '" value="Disable"></input>';
}
else {
return '<button href="#"' + 'id="'+ data + '">Edit</button> <input type="button" href="#"' + 'id="enable-'+ data + '" value="Enable"></input>';
}
}
based on status I am showing button either enable/disable.
Now I want to bind onclick event using JQuery.
I have bind one button using following way.
$('#tenantTable tbody').on( 'click', 'button', function () {
var data = table.row( $(this).parents('tr') ).data();
});
$('#tenantTable tbody').on( 'click', 'input[id="enable*"]', function () {
var data = table.row( $(this).parents('tr') ).data();
console.log('>> DISABLE <<');
});
$('#tenantTable tbody').on( 'click', 'input[id="disable*"]', function () {
var data = table.row( $(this).parents('tr') ).data();
console.log('>> DISABLE <<');
});
It is not working, Is there a way I can do the above?
'input[id="enable*"]'to'input[id*="enable"]'and'input[id*="disable"]'