Delete DataTable Row Check
Delete DataTable Row Check
kraftomatic
Posts: 78Questions: 13Answers: 0
Hey Allan,
I'm trying to add a check to the "delete row" function you helped me with, where it only triggers if there is a radio button in the "delete" column selected (currently it jumps into it if nothing is selected). I have the following with an added check, but it's not triggering correctly:
[code]
// Delete row button
$('#delete').click( function () {
var ids = [];
table.$('input.delete_row[type=radio]:checked').each( function () {
ids.push( $(this).parents('tr')[0].id );
} );
if ( $('input.delete_row[type=radio]:checked', this).length == 0 ) {
alert("show if no buttons are selected");
}
bootbox.confirm("Are you sure you want to delete these row(s)?", function(result) {
if (result == true) {
// moved code up into bootbox function
table.$('input.delete_row[type=radio]:checked').each( function () {
table.fnDeleteRow( $(this).parents('tr')[0], false );
} );
table.fnDraw();
}
});
} );
[/code]
The "show if no buttons are selected" alert shows regardless if a value is selected or not. Just trying to figure out what I'm doing wrong.
Thanks Much.
I'm trying to add a check to the "delete row" function you helped me with, where it only triggers if there is a radio button in the "delete" column selected (currently it jumps into it if nothing is selected). I have the following with an added check, but it's not triggering correctly:
[code]
// Delete row button
$('#delete').click( function () {
var ids = [];
table.$('input.delete_row[type=radio]:checked').each( function () {
ids.push( $(this).parents('tr')[0].id );
} );
if ( $('input.delete_row[type=radio]:checked', this).length == 0 ) {
alert("show if no buttons are selected");
}
bootbox.confirm("Are you sure you want to delete these row(s)?", function(result) {
if (result == true) {
// moved code up into bootbox function
table.$('input.delete_row[type=radio]:checked').each( function () {
table.fnDeleteRow( $(this).parents('tr')[0], false );
} );
table.fnDraw();
}
});
} );
[/code]
The "show if no buttons are selected" alert shows regardless if a value is selected or not. Just trying to figure out what I'm doing wrong.
Thanks Much.
This discussion has been closed.
Replies
if ( $('input.delete_row[type=radio]:checked').length != 0 ) {