Confirm delete on tabletools?
Confirm delete on tabletools?
Stpdude
Posts: 30Questions: 0Answers: 0
Heya, so ive got a ajax delete command tied into an ajax button and am trying to implement a confirm window on it, so the user clicks delete and it pops up asking them to confirm they want to delete it:
[code]
{
"sExtends": "ajax",
"bSelectedOnly": "true",
"sButtonText": "Delete Selected",
"mColumns": [0],
"bHeader": false,
"sAjaxUrl": "dataTable/delete/cmsGroup",
"fnAjaxComplete": function ( XMLHttpRequest, textStatus ) {
$('tr.DTTT_selected').remove();
}//delete button
},
[/code]
now i hand wrote it out using a function call, but its MUCH more complex then the simple button is:
[code]
{
"sExtends": "text",
"sButtonText": "Delete",
"fnClick": function(nButton, oConfig, nRow){
if (confirm('Are you sure want to delete this record?')) {
var list = $('tr.DTTT_selected > td.sorting_1 > a').map(function () {
return this.text;
}).get().join(",");
$.ajax({
type: "POST",
url: "dataTable/delete/cmsGroup",
data: 'tableData='+ list,
success: function(result) {
alert("Entry Deleted");
$('tr.DTTT_selected').remove();
}});
}}},[/code]
Anyone know how to tack that confirm onto the regular tabletools method?
[code]
{
"sExtends": "ajax",
"bSelectedOnly": "true",
"sButtonText": "Delete Selected",
"mColumns": [0],
"bHeader": false,
"sAjaxUrl": "dataTable/delete/cmsGroup",
"fnAjaxComplete": function ( XMLHttpRequest, textStatus ) {
$('tr.DTTT_selected').remove();
}//delete button
},
[/code]
now i hand wrote it out using a function call, but its MUCH more complex then the simple button is:
[code]
{
"sExtends": "text",
"sButtonText": "Delete",
"fnClick": function(nButton, oConfig, nRow){
if (confirm('Are you sure want to delete this record?')) {
var list = $('tr.DTTT_selected > td.sorting_1 > a').map(function () {
return this.text;
}).get().join(",");
$.ajax({
type: "POST",
url: "dataTable/delete/cmsGroup",
data: 'tableData='+ list,
success: function(result) {
alert("Entry Deleted");
$('tr.DTTT_selected').remove();
}});
}}},[/code]
Anyone know how to tack that confirm onto the regular tabletools method?
This discussion has been closed.
Replies
Your method of using fnClick to perform the actions you want looks correct to me.
Allan
'table tools method' i mean i was styling it off the TableTools buttons examples, using the listed ajax options.
What id like to do is use the styling in the first code block i posted. Using more simple commands, its cleaner and simpler to pass the mColumns [0] to pass the ID of my data over to the server for delete. However i want the user to be prompted to confirm deleting X number of rows. In my custom written block (2nd code block) ive written it all and wrapped it in a if confirm, i just havent been able to figure out how to implement that in my first code section.
Allan