I need to extend a javascript from the new ui module that features the new admin grid system. Extend a default Ui component give me a hint, and I was able to setup some code:

# file: app/code/My/Module/view/adminhtml/web/js/gid/massactions.js
console.log('new massactions.js');
], function (massactions) {
    console.log('before extend');
    return massactions.extend({

        defaultCallback: function (action, data) {
            console.log('custom callback');


As you can see, I have three console.log, but the defaultCallback one is not being called, so it is not overwriting the method as I expected, but I can be sure that the definition was loaded.

To be fair, I want to add a custom callback to a new action that I've added. In the original massactions.js, we have a _getCallback that attempts to grab a callback for a massaction item (fallback to defaultCallback, which I'm trying to overwrite), but I could not manage to add a callback there, even using view/ui_component/sales_order_grid.xml.

Any help will be very appreciated.

Update 1: I'm able to overwrite the method using massactions.prototype.defaultCallback = function(){}. I'm not sure if this have any collateral effect, so I'm leaving the question open.

  • Update: I'm able to overwrite the method using massactions.prototype.defaultCallback = function. In such case, what am I missing without using extend ? Jul 20 '15 at 17:59
  • Try to fix gid to grid. Jul 12 '17 at 18:33

Looks like answered on github. copy/past here

You can try 'mixins' feature, all you need is to create requireJS module with extended method like this:


define(function () {
    'use strict';

    var mixin = {

        methodToExtend: function () {

    return function (target) { // target == Result that Magento_Ui/.../default returns.
        return target.extend(mixin); // new result that all other modules receive 


config: {
    mixins: {
        'My_Module/js/payment/default': {  // Target module
            'My_Module/js/payment/default_mixin': true  // Extender module
  • 1
    I did the same, but My.js:37 Uncaught TypeError: target.extend is not a function. The only difference with example is adding define(['jquery', 'My_My/js/main'], function ($, my)
    – zhartaunik
    Oct 27 '16 at 11:03

I'm not sure what you want, but you can use my solution. I use mixins.

], function (/*massactions*/) {
    'use strict';

    return function (target) {
        return target.extend({
            applyAction: function (actionIndex) {
                console.log('my version');
                // call parent
                //return this._super(actionIndex);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.