I want to tidy up this answer i gave here:
How to disable a swatch, once it is been selected in Magento2.2?
Instead of completely overriding the function i would like to improve it by wrapping the original function call and adding my custom code after the original function like so:
define([
'jquery',
'mage/utils/wrapper'
], function ($, wrapper) {
'use strict';
return function(swatchRenderer){
var OnClickWrapper = wrapper.wrap(swatchRenderer.prototype._OnClick, function(originalSwatchRenderer){
var result = originalSwatchRenderer();
/*Custom code start*/
console.log(this);
//.css({"pointer-events":"none","opacity":"0.6"});
alert("test");
/*Custom code end*/
return result;
});
swatchRenderer.prototype._OnClick = OnClickWrapper;
return swatchRenderer;
};
});
This is mostly functioning ok however want to access the parameters passed to the original function so i can grab the parent of the clicked element with $this
:
_OnClick: function ($this, $widget, eventName)
Is it possible to access these from within the wrapper and and how to do so?