Jump to:

22976 Posts in 11620 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » How to override admin javascript functionalities?

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

Page: 1
Go to End
Author Topic: 1006 Views
  • ordinarywebguy
    Avatar
    Community Member
    13 Posts

    How to override admin javascript functionalities? Link to this post

    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 ?

  • ordinarywebguy
    Avatar
    Community Member
    13 Posts

    Re: How to override admin javascript functionalities? Link to this post

    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!

    1006 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.