Setting custom message for editor_remove modal
Setting custom message for editor_remove modal
I have a link on the page that I am capturing the remove event with:
$('#datatable_fixed_column').on('click', 'a.retire_record', function (e) {
e.preventDefault();
editor.remove( $(this).closest('tr') );
} );
This fires correctly and triggers:
editor.on('initRemove', function (e,node,data) {
editor
.message("Are you sure you want to Retire " + (data.length >1 ? data.length + " Records?" : "this Record?"))
.title( 'Retire Records' )
.buttons(
{
label: "Retire",
fn: function () { editor.submit(); }
}
);
});
So far so go, however, I have added a "Retire" button to the DataTable menu which does not work correctly.
"oTableTools": {
"sRowSelect": "os",
"aButtons": [
{
"sExtends": "editor_remove",
"sButtonText" : "Retire",
"editor": editor
},
'select_all',
"copy",
"csv",
"xls",
{
"sExtends": "pdf",
"sTitle": "Report",
"sPdfMessage": "PDF Export",
"sPdfSize": "letter"
},
{
"sExtends": "print",
"sMessage": "Generated by WebPage <i>(press Esc to close)</i>"
}
],
"sSwfPath": "js/plugin/datatables/swf/copy_csv_xls_pdf.swf"
},
The Retire button does fire initRemove and does process the editor updates to Title, Message, and Buttons. But when the modal shows up, it has the default messaging: "Delete", "Are you sure you want to delete 5 rows?", "Delete".
Thanks in advance for any help!
This discussion has been closed.
Answers
After some playing around, I found that if I set the value for these elements in the "open" event they populate correctly. It would appear they are being overridden from the "initRemove" event.