Jump to:

520 Posts in 248 Topics by 263 members

Content Editor Discussions

SilverStripe Forums » Content Editor Discussions » Usability Issue - Unintentionally deleting new pages

Forum for content editors and CMS users.

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

Page: 1
Go to End
Author Topic: 1333 Views
  • dan.lexisclick
    Avatar
    Community Member
    1 Post

    Usability Issue - Unintentionally deleting new pages Link to this post

    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.

  • Tama
    Avatar
    Community Member
    130 Posts

    Re: Usability Issue - Unintentionally deleting new pages Link to this post

    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');

    1333 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.