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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

How to override admin javascript functionalities?


2 Posts   1113 Views


2 August 2010 at 7:45pm Community Member, 13 Posts

As oppose with this solution, 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 ?


4 August 2010 at 11:55pm (Last edited: 4 August 2010 11:57pm), Community Member, 13 Posts

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
      '#Form_EditForm_Comments a.delete-link': {
         initialize: function() {
            jQuery(this).unbind('click'); //unbind default behavior
         onclick : function(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() {
               // Execute deletion
               new Ajax.Request(target.attr('href'), options);

Hope it'll be a help!