Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Content Editor Discussions /

Forum for content editors and CMS users.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

Usability Issue - Unintentionally deleting new pages


Go to End
Reply


2 Posts   1608 Views

Avatar
dan.lexisclick

Community Member, 1 Post

10 April 2010 at 1:04am

Currently using the latest pre release rc1

When creating a new page and editing the content, pressing tab will highlight the next button which is "Delete from draft site".

Pressing enter at this point will delete the page you are working on with no confirmation prompt.

Just lost me a huge article so I thought i'd point it out.

Avatar
Tama

Community Member, 133 Posts

4 November 2010 at 8:48am

Hi, we had issues with CMS users accidentally unpublishing/ deleting pages (and their children). I add this piece of Javascript to inject a confirm pop-up onto the "Unpublish" and "Delete" buttons:

// Add popup to Unpublish box when mouse enters div containing action buttons. This is bound via live as the action buttons can be rebuilt with AJAX.
jQuery('#form_actions_right').live('mouseenter', function() {

    //Check if Unpublish button needs to be disabled
    if (jQuery('#Form_EditForm_action_unpublish').attr('name') != '') {

        //Disable Unpublish Button
        jQuery('#Form_EditForm_action_unpublish').attr('name', '');

        //Bind Mousedown event handler to Unpublish button. Mouseover is used instead of click to avoid conflict 
        jQuery('#Form_EditForm_action_unpublish').mousedown(function() {
            //Display confirmation box if there is mousedown on Unpublish button
            confirm_box = confirm("Unpublishing this page will also unpublish all of it's child pages");
            //If OK is clicked on confirmation box enable button and resubmit
            if (confirm_box == true) {
                //Enable Unpublish Button
                jQuery('#Form_EditForm_action_unpublish').attr('name', 'action_unpublish');
                //Trigger click on Unpublish button to set submit in motion
                jQuery('#Form_EditForm_action_unpublish').click();
                return true;
            }
        });

    }

    //Check if Delete button needs to be disabled
    if (jQuery('#Form_EditForm_action_delete').attr('name') != '') {

        //Disable Delete Button
        jQuery('#Form_EditForm_action_delete').attr('name', '');

        //Bind Mousedown event handler to Delete button. Mouseover is used instead of click to avoid conflict 
        jQuery('#Form_EditForm_action_delete').mousedown(function() {
            //Display confirmation box if there is mousedown on Delete button
            confirm_box = confirm("Are you sure you want to Delete this page?");
            //If OK is clicked on confirmation box enable button and resubmit
            if (confirm_box == true) {
                //Enable Delete Button
                jQuery('#Form_EditForm_action_delete').attr('name', 'action_delete');
                //Trigger click on Delete button to set submit in motion
                jQuery('#Form_EditForm_action_delete').click();
                return true;
            }
        });
    }
});

Put this in a Javascript file called mysite/javascript/unpublishbutton.js and add the following code to /mysite/_config.php

LeftAndMain::require_javascript('mysite/javascript/unpublishbutton.js');