Okay
  Public Ticket #2598149
Confirm Deletion There Is No Undo
Closed

Comments

  •  2
    Marian Harris started the conversation

    Hi there,

    I would like one of my tables, which is front-end editable, to not show the warning popup:  "Are you sure? Confirm deletion.  There is no undo" when a user attempts to delete a row.

    Is it possible to completely eliminate this popup message?  Either for this table absolutely or for a particular page?  

    Thanks for any suggestions.


  •  2,572
    Aleksandar replied

    Hello Marian

    It can be done, but you need to change wpdatatables.js, and turn off "Use minified wpDataTables Javascript" option in wpDataTables settings/Custom JS and CSS tab. Also, after the plugin is updated, you will need to do it again, since the changes will be overwritten.

    In file wp-content/plugins/wpdatatables/assets/js/wpdatatables/wpdatatables.js around line 1324 you will find this:

    /**
                     * Delete an entry dialog
                     */
                    $('.delete_table_entry[aria-controls="' + tableDescription.tableId + '"]').click(function (e) {
                        e.preventDefault();
                        e.stopImmediatePropagation();
                        if ($(this).hasClass('disabled')) {
                            return false;
                        }
                        $('.wpDataTablesPopover.editTools').hide();
                        var modal =  $('#wdt-delete-modal');
                        modal.find('.modal-footer').html('');
                        modal.find('.modal-footer').append($(tableDescription.selector + '_delete_dialog_buttons').show());
                        modal.modal('show');
                        $(tableDescription.selector + '_wdt-browse-delete-button').click(function (e) {
                            e.preventDefault();
                            e.stopImmediatePropagation();
                            if (['manual', 'mysql'].indexOf(tableDescription.tableType) === -1) {
                                if(typeof wpDataTablesEditors[tableDescription.tableType]['delete'] == 'function') {
                                    wpDataTablesEditors[tableDescription.tableType]['delete'](tableDescription);
                                }
                            } else {
                                var row = $(tableDescription.selector + ' tr.selected').get(0);
                                var data = wpDataTables[tableDescription.tableId].fnGetData(row);
                                var id_val = data[tableDescription.idColumnIndex];
                                $.ajax({
                                    url: tableDescription.adminAjaxBaseUrl,
                                    type: 'POST',
                                    data: {
                                        action: 'wdt_delete_table_row',
                                        id_key: tableDescription.idColumnKey,
                                        id_val: id_val,
                                        table_id: tableDescription.tableWpId,
                                        wdtNonce: $('#wdtNonceFrontendEdit_' + tableDescription.tableWpId).val()
                                    },
                                    success: function () {
                                        wpDataTables[tableDescription.tableId].fnDraw(false);
                                        $('#wdt-delete-modal').modal('hide');
                                        wdtNotify(wpdatatables_edit_strings.success, wpdatatables_edit_strings.rowDeleted, 'success')
                                    }
                                });
                            }
                        });
                    });

    And replace it with this:

    //**
                     * Delete an entry dialog
                     */
                    $('.delete_table_entry[aria-controls="' + tableDescription.tableId + '"]').click(function (e) {
                        e.preventDefault();
                        e.stopImmediatePropagation();
                        if ($(this).hasClass('disabled')) {
                            return false;
                        }
                        if (tableDescription.tableWpId != 1356){
                            $('.wpDataTablesPopover.editTools').hide();
                            var modal =  $('#wdt-delete-modal');
                            modal.find('.modal-footer').html('');
                            modal.find('.modal-footer').append($(tableDescription.selector + '_delete_dialog_buttons').show());
                            modal.modal('show');
                            $(tableDescription.selector + '_wdt-browse-delete-button').click(function (e) {
                                e.preventDefault();
                                e.stopImmediatePropagation();
                                if (['manual', 'mysql'].indexOf(tableDescription.tableType) === -1) {
                                    if(typeof wpDataTablesEditors[tableDescription.tableType]['delete'] == 'function') {
                                        wpDataTablesEditors[tableDescription.tableType]['delete'](tableDescription);
                                    }
                                } else {
                                    var row = $(tableDescription.selector + ' tr.selected').get(0);
                                    var data = wpDataTables[tableDescription.tableId].fnGetData(row);
                                    var id_val = data[tableDescription.idColumnIndex];
                                    $.ajax({
                                        url: tableDescription.adminAjaxBaseUrl,
                                        type: 'POST',
                                        data: {
                                            action: 'wdt_delete_table_row',
                                            id_key: tableDescription.idColumnKey,
                                            id_val: id_val,
                                            table_id: tableDescription.tableWpId,
                                            wdtNonce: $('#wdtNonceFrontendEdit_' + tableDescription.tableWpId).val()
                                        },
                                        success: function () {
                                            wpDataTables[tableDescription.tableId].fnDraw(false);
                                            $('#wdt-delete-modal').modal('hide');
                                            wdtNotify(wpdatatables_edit_strings.success, wpdatatables_edit_strings.rowDeleted, 'success')
                                        }
                                    });
                                }
                            });
                        } else {
                                if (['manual', 'mysql'].indexOf(tableDescription.tableType) === -1) {
                                    if(typeof wpDataTablesEditors[tableDescription.tableType]['delete'] == 'function') {
                                        wpDataTablesEditors[tableDescription.tableType]['delete'](tableDescription);
                                    }
                                } else {
                                    var row = $(tableDescription.selector + ' tr.selected').get(0);
                                    var data = wpDataTables[tableDescription.tableId].fnGetData(row);
                                    var id_val = data[tableDescription.idColumnIndex];
                                    $.ajax({
                                        url: tableDescription.adminAjaxBaseUrl,
                                        type: 'POST',
                                        data: {
                                            action: 'wdt_delete_table_row',
                                            id_key: tableDescription.idColumnKey,
                                            id_val: id_val,
                                            table_id: tableDescription.tableWpId,
                                            wdtNonce: $('#wdtNonceFrontendEdit_' + tableDescription.tableWpId).val()
                                        },
                                        success: function () {
                                            wpDataTables[tableDescription.tableId].fnDraw(false);
                                            wdtNotify(wpdatatables_edit_strings.success, wpdatatables_edit_strings.rowDeleted, 'success')
                                        }
                                    });
                                }
                        }
                    });
    

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2
    Marian Harris replied

    Hi Aleksandar,

    Thank you very much! 

    I replaced the old code with the new code in the wpdatatables.js file and turned off the minified option in Settings.  

    It works beautifully in the back end -- as long as I use "Excel-like" view.  The data is all visible and if I delete a row there is no 'confirm deletion' popup.  Which is fabulous.

    The only problem is that in standard view in the back end (and everywhere on the front end) none of my 100+ wpdatatables can remember their data. 

    I'm attaching screenshots to show you what they look like on the back end.  On the front end they refuse to show up at all.


    P.S.  Thinking maybe the problem was elsewhere, I tried...

    Reverting to the old code, and that fixes everything -- but then I get the confirm-deletion popup back.

    Switching again to the new code -- same problem as described.


    Thanks again. 


  •  2,572
    Aleksandar replied

    You're welcome, Marian

    I'm not sure why it's behaving like this, so I forwarded the ticket to one of our developers.

    As soon as he checks it out I will get back to you.

    I have to apologize for the delay up front, because they are currently working on some priority fixes for the plugin and it may be a few days until this is resolved.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2,572
    Aleksandar replied

    Hi again Marian

    Looks like I made a mistake when I pasted the code - I pasted an extra forward-slash in the beginning (check the screenshot below):

    2310485599.png

    So delete that, or copy the corrected code:

    /**
                     * Delete an entry dialog
                     */
                    $('.delete_table_entry[aria-controls="' + tableDescription.tableId + '"]').click(function (e) {
                        e.preventDefault();
                        e.stopImmediatePropagation();
                        if ($(this).hasClass('disabled')) {
                            return false;
                        }
                        if (tableDescription.tableWpId != 1356){
                            $('.wpDataTablesPopover.editTools').hide();
                            var modal =  $('#wdt-delete-modal');
                            modal.find('.modal-footer').html('');
                            modal.find('.modal-footer').append($(tableDescription.selector + '_delete_dialog_buttons').show());
                            modal.modal('show');
                            $(tableDescription.selector + '_wdt-browse-delete-button').click(function (e) {
                                e.preventDefault();
                                e.stopImmediatePropagation();
                                if (['manual', 'mysql'].indexOf(tableDescription.tableType) === -1) {
                                    if(typeof wpDataTablesEditors[tableDescription.tableType]['delete'] == 'function') {
                                        wpDataTablesEditors[tableDescription.tableType]['delete'](tableDescription);
                                    }
                                } else {
                                    var row = $(tableDescription.selector + ' tr.selected').get(0);
                                    var data = wpDataTables[tableDescription.tableId].fnGetData(row);
                                    var id_val = data[tableDescription.idColumnIndex];
                                    $.ajax({
                                        url: tableDescription.adminAjaxBaseUrl,
                                        type: 'POST',
                                        data: {
                                            action: 'wdt_delete_table_row',
                                            id_key: tableDescription.idColumnKey,
                                            id_val: id_val,
                                            table_id: tableDescription.tableWpId,
                                            wdtNonce: $('#wdtNonceFrontendEdit_' + tableDescription.tableWpId).val()
                                        },
                                        success: function () {
                                            wpDataTables[tableDescription.tableId].fnDraw(false);
                                            $('#wdt-delete-modal').modal('hide');
                                            wdtNotify(wpdatatables_edit_strings.success, wpdatatables_edit_strings.rowDeleted, 'success')
                                        }
                                    });
                                }
                            });
                        } else {
                                if (['manual', 'mysql'].indexOf(tableDescription.tableType) === -1) {
                                    if(typeof wpDataTablesEditors[tableDescription.tableType]['delete'] == 'function') {
                                        wpDataTablesEditors[tableDescription.tableType]['delete'](tableDescription);
                                    }
                                } else {
                                    var row = $(tableDescription.selector + ' tr.selected').get(0);
                                    var data = wpDataTables[tableDescription.tableId].fnGetData(row);
                                    var id_val = data[tableDescription.idColumnIndex];
                                    $.ajax({
                                        url: tableDescription.adminAjaxBaseUrl,
                                        type: 'POST',
                                        data: {
                                            action: 'wdt_delete_table_row',
                                            id_key: tableDescription.idColumnKey,
                                            id_val: id_val,
                                            table_id: tableDescription.tableWpId,
                                            wdtNonce: $('#wdtNonceFrontendEdit_' + tableDescription.tableWpId).val()
                                        },
                                        success: function () {
                                            wpDataTables[tableDescription.tableId].fnDraw(false);
                                            wdtNotify(wpdatatables_edit_strings.success, wpdatatables_edit_strings.rowDeleted, 'success')
                                        }
                                    });
                                }
                        }
                    });

    And that should do it.

    Please let me know.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  •  2
    Marian Harris replied

    Hi again Aleksandar,

    My heartfelt thanks.

    This works beautifully and my visitors will be much happier, I think.

    Thanks again.

    Marian


  •  2,572
    Aleksandar replied

    You're welcome, Marian

    Glad I could be of service, and sorry for the error.

    If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.

    Kind Regards, 

    Aleksandar Vuković
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables