As oppose with this solution http://silverstripe.org/dataobjectmanager-module-forum/show/268741#post268741, I don't wan't to mess-up with core javascript. What's the best workaround to customize javascript functionalities specifically on admin and this script dataobject_manager/javascript/dataobject_manager.js ?
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.
After couple of hours solving the scenario, I was able to find a solution. Though it's kinda ugly combining prototype js and jquery co'z jQuery.ajax wasn't executing within Behaviour.register. See code below.
// Customize admin comment delete behavior
// Added delete confirmation
// @see dataobject_manager/javascript/dataobject_manager.js
Behaviour.register({
'#Form_EditForm_Comments a.delete-link': {
initialize: function() {
jQuery(this).unbind('click'); //unbind default behavior
},
onclick : function(event) {
Event.stop(event);
// Now show up confirmation message
deleteIt = confirm('Are you sure you want to delete this comment?');
if( deleteIt ) {
target = jQuery(this);
params = $('SecurityID') ? {'forceajax' : '1', 'SecurityID' : $('SecurityID').value} : {'forceajax' : '1'};
var options = {
method: 'post',
parameters : params,
onSuccess: function() {
jQuery(target).parents('li:first').fadeOut();
jQuery('.ajax-loader').fadeOut('fast');
}
};
// Execute deletion
new Ajax.Request(target.attr('href'), options);
}
}
}
});
Hope it'll be a help!