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');
define([
'Magento_Ui/js/grid/massactions'
], 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.
massactions.prototype.defaultCallback = function
. In such case, what am I missing without usingextend
?