I’m writing a mixin for vendor/magento/module-checkout/view/frontend/web/js/sidebar.js
I need to add extra events to
_initContent: function () {
var self = this,
events = {};
this.element.decorate('list', this.options.isRecursive);
/**
* @param {jQuery.Event} event
*/
events['click ' + this.options.button.close] = function (event) {
event.stopPropagation();
$(self.options.targetElement).dropdownDialog('close');
};
events['click ' + this.options.button.checkout] = $.proxy(function () {
var cart = customerData.get('cart'),
customer = customerData.get('customer'),
element = $(this.options.button.checkout);
if (!customer().firstname && cart().isGuestCheckoutAllowed === false) {
// set URL for redirect on successful login/registration. It's postprocessed on backend.
$.cookie('login_redirect', this.options.url.checkout);
if (this.options.url.isRedirectRequired) {
element.prop('disabled', true);
location.href = this.options.url.loginUrl;
} else {
authenticationPopup.showModal();
}
return false;
}
element.prop('disabled', true);
location.href = this.options.url.checkout;
}, this);
...
this._on(this.element, events);
this._calcHeight();
},
but inside a mixin I can’t access the events
object
define([
'jquery'
], function ($) {
'use strict';
return function (widget) {
$.widget('mage.sidebar', widget, {
_initContent: function () {
this._super();
/**
* @param {jQuery.Event} event
*/
events['click ' + '.minicart-items-wrapper .qty-increase'] = function (event) {
console.log('increase')
};
/**
* @param {jQuery.Event} event
*/
events['click ' + '.minicart-items-wrapper .qty-decrease'] = function (event) {
console.log('decrease');
};
this._on(this.element, events);
},
});
return $.mage.sidebar;
};
});
it says events is not defined