Precondition
I have 2 custom widgets extending same parent widget.
- Parent widget:
Magento_ConfigurableProduct/js/configurable
- First Custom Widget:
Vendor_AModule/js/configurable
- Second Custom Widget:
Vendor_BModule/js/configurable
First Custom Widget require-config.js
:
var config = {
map: {
'*': {
configurable: 'Vendor_AModule/js/configurable'
}
}
};
First Custom Widget JS:
define([
'jquery',
'mage/translate',
'Magento_ConfigurableProduct/js/configurable'
], function ($) {
$.widget('vendor.configurable_awidget', $.mage.configurable, {
/**
* {@inheritDoc}
*/
_configureElement: function (element) {
this._super(element);
alert('Custom widget A is triggered!');
}
});
return $.vendor.configurable_awidget;
});
Second Custom Widget require-config.js
:
var config = {
map: {
'*': {
configurable: 'Vendor_BModule/js/configurable'
}
}
};
Second Custom Widget JS:
define([
'jquery',
'mage/translate',
'Magento_ConfigurableProduct/js/configurable'
], function ($) {
$.widget('vendor.configurable_bwidget', $.mage.configurable, {
/**
* {@inheritDoc}
*/
_configureElement: function (element) {
this._super(element);
alert('Custom widget B is triggered!');
}
});
return $.vendor.configurable_bwidget;
});
Steps to reproduce
I open a configurable product frontend page.
Expected Result
I see both Custom widget B is triggered!
and Custom widget A is triggered!
alert.
Actual Result
I only see Custom widget B is triggered!
alert.
Question
How should the code be to make the configurable product frontend page displays alerts of both widgets?