I am trying to extend the default dropdown.js of Magento
1) Created a new JS file at app/design/frontend/<vendor>/<theme-name>/web/js/mage/dropdown.js
define([
"jquery",
"jquery/ui",
"mage/dropdown"
], function($){
'use strict';
$.widget('mage.customdropdownDialog', $.mage.dropdownDialog, {
_create: function() {
this._super();
console.log("Testing...");
},
});
return $.mage.customdropdownDialog;
});
2) Added reference in the requirejs-config.js
at app/design/frontend/<vendor>/<theme-name>/requirejs-config.js
var config = {
map: {
"*": {
"dropdownDialog": "js/mage/dropdown"
}
}
};
3) Ran php bin/magento setup:upgrade
and php bin/magento setup:static-content:deploy
I keep getting the following error whenever I try to click on any dropdown created using the dropdown.js libary.
Uncaught Error: cannot call methods on dropdownDialog prior to initialization; attempted to call method 'close'
I am not sure what I am doing wrong, can anyone please help me with this ?