21302 Posts in 5736 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 850 Views |
-
How to override admin javascript functionalities?

2 August 2010 at 7:45pm
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 ?
-
Re: How to override admin javascript functionalities?

4 August 2010 at 11:55pm Last edited: 4 August 2010 11:57pm
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!
| 850 Views | ||
|
Page:
1
|
Go to Top |

