So seeing how you got this working made me look into a bit more and see a few possibilities. A while ago I asked you how I could add delete confirmation on the DOM and now it is relatively straightforward.
In my project page class I added the following code
$projectfield->removePermission("delete");
to turn off the main delete button. I then added to the dataobject a delete function and a new DataObjectManagerAction
public function confirmDelete()
{
if($this)
$this->delete();
else
{
}
}
new DataObjectManagerAction(
'Delete Project',
"http://synergysilverstripelatest/admin/EditForm/field/Projects/item/$this->ID/delete",
"delete-confirm",
"/assets/graphics/$deleteImage"
));
notice I called 'delete-confirm' my new $behaviour javascript function which I placed in dataobject_manager.js
$container.find('a.delete-link-synergy-test-edit').unbind('click').click(function(e) {
alert('this works cause its wills test');
var answer = confirm('Do you want to delete this?');
if (answer){
alert("You deleted it!");
params = $('#SecurityID') ? {'forceajax' : '1', 'SecurityID' : $('#SecurityID').attr('value')} : {'forceajax' : '1'};
$target = $(this);
$.post(
$target.attr('href'),
params,
function() {$($target).parents('li:first').fadeOut();$(".ajax-loader").fadeOut("fast");}
);
e.stopPropagation();
return false;
}
else
{
alert("Thanks for sticking around!");
return false;
}
});
where I just copied your delete function and added a confirm function in there. At the moment I just edited the dataobject_manager.js which works but is obviously a bad way to do it as it will be deleted come upgrade time.
I tried creating a new class called WillsDataObjectManagerAction.php which wasn't too big as it just had the DataObjectManagerAction in it but it had to call a new copy of dataobject_manager.js called willsdataobject_manager.js which worked too but I am wondering is this a bad way to do it cause it's a big js file and if I keep using my copy of it's current state it will gradually get more out of date. Is it better to do this or just edit the main js file every upgrade. How much is the js file likely to change I guess I'm asking as well. Thanks. Hope this helps someone.