Question about changing the default form for Editor's Delete

Question about changing the default form for Editor's Delete

ChilllburgerChilllburger Posts: 1Questions: 1Answers: 0

Hello, I'm using Editor via a licensing deal with my employer and I have a few questions about changing some of the behavior.

When clicking on a row, you usually get a pop up asking you "Are you sure you wish to delete 1 row?". Is there anyway to change this default message with the Editor API? Also, is it possible to move the 'x' cancel button's functionality to a cancel button beside the 'Delete' button on the bottom of the form?

Thanks!

Answers

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Is there anyway to change this default message with the Editor API?

    Absolutely - the i18n.remove.confirm option can be used to change the message.

    Another option is to use the message() option can be used to change the form message. You could listen for the open event and call message() when the remove form type is shown.

    Also, is it possible to move the 'x' cancel button's functionality to a cancel button beside the 'Delete' button on the bottom of the form?

    You could add another button using the buttons() method (in this case would would need to use open). The x would remain (you could remove it using CSS, but there isn't a way to target it for just the remove form I think), but the functionality would then be consistent.

    Regards,
    Allan

  • SteveAmerigeSASSteveAmerigeSAS Posts: 5Questions: 1Answers: 0
    edited April 2015

    I'm encountering a bit of an issue using the included APIs.

    In my current page, I'm trying to set a custom message for the 'remove' action, like so:

       i18n: {
          remove: {
            confirm: {
                    _: "Confirm deletion of %d records.",
                    1: "Confirm deletion of record."
            }           
          }
    

    This occurs within the definition of the editor object.
    But on my page, the delete function does not seem to create the message correctly.
    Here is a screenshot of the resulting message:
    http://i.imgur.com/YkXyFmA.png

    Any idea for why the message text is not rendering?

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    I've just tried the code above in a local example and it appears to work as expected. Could you show me the full Javascript that you are using for the Editor and DataTables initialisation?

    It looks like the message might be getting set somewhere else and as a string rather than the object with _ and 1 properties (hence the single character selection from the string - perhaps there were six rows selected for the screenshot for example?).

    Thanks,
    Allan

  • SteveAmerigeSASSteveAmerigeSAS Posts: 5Questions: 1Answers: 0

    I've managed to get the form message to change correctly using the i18n option, turns out to be an issue else where in my code.

    I was also trying to add a custom cancel button to my delete code using the button() method but am having some issues getting it to work. Can you look over my code here to see if I'm doing anything incorrectly?

    editor.on('open', function() {
        jQuery(document).on('a.delete-row', function(e) {
            editor.title("Delete VM").buttons ( [
                {
                    label: 'Cancel', fn: function() { 
                        this.close(); 
                    }
                }, 
                {
                    label: 'Delete', fn: function() {
                        this.submit();
                    }
                }
            ]).remove()
    
        });
    });
    

    Thanks a bunch!

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    That looks like it should work okay. I'm guessing it doesn't though?

    Try this:

    editor.on('open', function() {
        jQuery(document).on('a.delete-row', function(e) {
            editor.remove( $(this).closest('tr'), {
                title: "Delete VM",
                buttons: [
                    {
                        label: 'Cancel', fn: function() {
                            this.close();
                        }
                    },
                    {
                        label: 'Delete', fn: function() {
                            this.submit();
                        }
                    }
                ]
            } );
        });
    });
    

    Two changes:

    1. I've use the other form of the remove() method which should be a little more resilient to any timing errors if you are using inline editing.
    2. It wasn't deleting anything before :-). I've added $(this).closest('tr').

    Regards,
    Allan

  • SteveAmerigeSASSteveAmerigeSAS Posts: 5Questions: 1Answers: 0

    I'm still getting no changes to the Delete form. The i18n option seems to be the only method that results in any changes.

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Are you able to PM me a link to the page so I can debug it please? Just click on my user name above and then the "Send Message" button.

    Allan

  • SteveAmerigeSASSteveAmerigeSAS Posts: 5Questions: 1Answers: 0

    We do not have a public link, since it's for an internal website.

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    Can you drop me through the full Javascript that you are using in that case so I can try to recreate the issue and debug it?

    Thanks,
    Allan

This discussion has been closed.