@UC: Here's the updated patch. Is this more like what you had in mind?
- ORIGINAL CODE - - - - - - - - - - - - - - - -
$.post($target.attr('href'),params,function() {$($target).parents('li:first').fadeOut();$(".ajax-loader").fadeOut("fast");});
- PATCHED CODE - - - - - - - - - - - - - - - - -
$div.fadeOut("fast");
request = $.ajax({
cache: false,
url: $target.attr('href'),
data: params,
error: function(xhr){statusMessage(xhr.responseText,'bad');},
success: function(message){
statusMessage(message,'good');
$($target).parents('li:first').fadeOut();
$(".ajax-loader").fadeOut("fast");
}
});
- - - - - - - - - - - - - - - - - - - - - - - -
Usage:
class MyClass extends DataObject {
...
function onBeforeDelete()
{
// 2.3 compatibility
$class = class_exists('SS_HTTPResponse') ? 'SS_HTTPResponse' : 'HTTPResponse';
if(<check if object can be deleted>)
{
parent::onBeforeDelete();
// Send success message
$response = new $class("Item successfully deleted");
$response->output();
}
else
{
// Send error message
$response = new $class("Cannot delete this item", 401);
$response->output();
exit; // Stop the object from being deleted
}
}
}