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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Simple way to add delete confirmation in DataObjectManager?


Go to End


6 Posts   2547 Views

Avatar
vancouverWill

Community Member, 121 Posts

11 September 2009 at 5:12am

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

11 September 2009 at 6:06am

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

Avatar
vancouverWill

Community Member, 121 Posts

11 September 2009 at 6:57am

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

Avatar
vancouverWill

Community Member, 121 Posts

11 September 2009 at 6:59am

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

Avatar
zenmonkey

Community Member, 545 Posts

11 September 2009 at 5:20pm

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

Avatar
Krato

Community Member, 7 Posts

22 December 2009 at 5:39am

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