My code:
define([
'Magento_Customer/js/model/authentication-popup',
'Magento_Ui/js/modal/alert',
'Magento_Ui/js/modal/confirm',
'underscore',
'jquery/ui',
'jquery-ui-modules/core',
'jquery-ui-modules/widget',
'mage/decorate',
'mage/collapsible',
'mage/cookies',
'loader'
], function ($, authenticationPopup, customerData, alert, confirm, _) {
'use strict';
return function (widget) {
$.widget('mage.sidebar', widget, {
_updateItemQty: function (elem) {
var itemId = elem.data('cart-item');
var btnplus = elem.data('btn-plus');
var btnminus = elem.data('btn-minus');
$('#cart-item-' + itemId + '-qty').trigger('processStart');
this._ajax(this.options.url.update, {
'item_id': itemId,
'item_qty': $('#cart-item-' + itemId + '-qty').val(),
'item_btn_plus': btnplus,
'item_btn_minus': btnminus,
}, elem, this._updateItemQtyAfter);
$('#cart-item-' + itemId + '-qty').trigger('processStop');
this._customerData();
},
/**
* Update content after update qty
*
* @param {HTMLElement} elem
*/
_updateItemQtyAfter: function (elem) {
var productData = this._getProductById(Number(elem.data('cart-item')));
if (!_.isUndefined(productData)) {
$(document).trigger('ajax:updateCartItemQty');
if (window.location.href === this.shoppingCartUrl) {
window.location.reload(false);
}
}
this._hideItemButton(elem);
},
_customerData : function () {
var sections = ['cart'];
customerData.invalidate(sections);
customerData.reload(sections, true);
}
}
);
return $.mage.sidebar;
}
});
Console Error 1 : https://snipboard.io/4NK3b5.jpg
Console Error 2 : https://snipboard.io/iqX8yF.jpg
Module : https://github.com/kirtinariya1/MinicartAjaxQtyIncrementDecrement