Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Simple way to add delete confirmation in DataObjectManager?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1641 Views
  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Simple way to add delete confirmation in DataObjectManager? Link to this post

    IS there a simple way to add delete confirmation in DataObjectManager? I can see how to turn off the delete option but I don't want that. The problem is I find the edit and delete buttons are right next to each other and if I accidentaly hit the delete button then I lose an entry and I have hundreds of objects so then it is really hard to know what I have lost.

    I guess I could get into the javascript myself and add confirmation but wondered if there is a more straightforward and futureproof way than editing the source.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Simple way to add delete confirmation in DataObjectManager? Link to this post

    That's a good idea. I'll add that in.

  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Re: Simple way to add delete confirmation in DataObjectManager? Link to this post

    Glad you like it. I would be hesitant to use it in a client site without it cause of risk of losing data.

  • vancouverWill
    Avatar
    Community Member
    121 Posts

    Re: Simple way to add delete confirmation in DataObjectManager? Link to this post

    I suppose I could just use complextablefield for the time being, just noticed that does have the delete option. Thanks for the quick replies too

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Simple way to add delete confirmation in DataObjectManager? Link to this post

    How do you turn off the Delete? Mine has disappeared but I don't remember ever turning it off .

  • Krato
    Avatar
    Community Member
    7 Posts

    Re: Simple way to add delete confirmation in DataObjectManager? Link to this post

    I have managed to add delete confirmation by adding 3 lines of code to the file: dataobject_manager/javascript/dataobject_manager.js

    Line 71

    // Delete

    $container.find('a.delete-link').unbind('click').click(function(e) {
       params = $('#SecurityID') ? {'forceajax' : '1', 'SecurityID' : $('#SecurityID').attr('value')} : {'forceajax' : '1'};
       $target = $(this);
       deleteConfirmation = confirm('Do you really want to delete the selected item?');
       if(deleteConfirmation) {
          $.post(
             $target.attr('href'),
             params,
             function() {$($target).parents('li:first').fadeOut();$(".ajax-loader").fadeOut("fast");}
          );
       }
       e.stopPropagation();
       return false;
    });

    Hope this helps,
    Daniel

    1641 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.