Setting custom message for editor_remove modal

Setting custom message for editor_remove modal

tmelhisertmelhiser Posts: 2Questions: 1Answers: 0
edited October 2015 in Editor

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!

Answers

  • tmelhisertmelhiser Posts: 2Questions: 1Answers: 0

    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.

            var removalMessage;
            var removalTitle;
            
            editor.on('initRemove', function (e,node,data) {
                removalMessage = "Are you sure you want to Retire " + (data.length >1 ? data.length + " Rows?" : "this Row?");
                removalTitle = "Retire "+ (data.length >1 ? "Rows" : "Row");
            });
            
            editor.on('open', function (e,mode,action) {
                editor
                .message(removalMessage)
                .title( removalTitle )
                .buttons(
                    { 
                        label: removalTitle,
                        fn: function () { editor.submit(); }
                    }
                );
            });
    
This discussion has been closed.