1

Hi I have created a mixin but it gives the error "mixin is not a function".

Vendor/CustomCustomer/view/base/web/customercustom.js

define([
    'jquery',
    'underscore',
    'uiRegistry',
    'Magento_Ui/js/form/element/select',
    'domReady!'
], function ($,_, uiRegistry, Select) {
    'use strict';
    $(function() {
    return function (Select) {
        return Select.extend({
            initialize: function (value) {
                this._super();
                var customerCompany = uiRegistry.get('index = customer_company');
                var defaultCompany = uiRegistry.get('index = extension_attributes.company_attributes.company_id');
                var vessels = uiRegistry.get('index = customer_vessels');
                var customerUsername = uiRegistry.get('index = customer_username');
                var password = uiRegistry.get('index = password');
                var cnfpassword = uiRegistry.get('index = confirm_password');
                if (this.value() != 1) {
                    customerCompany.show();
                    defaultCompany.hide();
                    vessels.show();
                    customerUsername.show();
                    password.show();
                    cnfpassword.show();
                } else {
                    customerCompany.hide();
                    defaultCompany.show();
                    vessels.hide();
                    customerUsername.hide();
                    password.hide();
                    cnfpassword.hide();
                }                
                return this;
            },
            onUpdate: function (value) {
                var customerCompany = uiRegistry.get('index = customer_company');
                var defaultCompany = uiRegistry.get('index = extension_attributes.company_attributes.company_id');
                var vessels = uiRegistry.get('index = customer_vessels');
                var customerUsername = uiRegistry.get('index = customer_username');
                var password = uiRegistry.get('index = password');
                var cnfpassword = uiRegistry.get('index = confirm_password');
                if (value != 1) {
                    customerCompany.show();
                    defaultCompany.hide();
                    customerUsername.show();
                    password.show();
                    cnfpassword.show();
                } else {
                    customerCompany.hide();
                    defaultCompany.show();
                    customerUsername.hide();
                    password.hide();
                    cnfpassword.hide();
                    vessels.hide();
                }

                return this._super();
            },
        });
    }
});
  });

Vendor/CustomCustomer/view/base/requirejs-config.js

var config = {
    'config': {
        'mixins': {
            'Magento_Ui/js/form/element/website': {
                'Vendor_CustomCustomer/customercustom': true
            }
        }
    }
};
0

You probably need to check and change the location of your mixin.
Refer to the documentation

Update: Remove single quotes in your mixins declaration:
reference

var config = {
    config: {
        mixins: {
            'Magento_Ui/js/form/element/website': {
                'Vendor_CustomCustomer/customercustom': true
            }
        }
    }
};
  • Thanks for the response magefms. I have changed the location of my mixin to js/form/element/customercustom. But it is still giving the same error. Please help. – Meetali Gupta May 3 at 9:21
  • you mean web/js/form/element/customercustom ? – fmsthird May 3 at 9:31
  • Yes web/js/form/element/customercustom – Meetali Gupta May 3 at 10:18
  • so in your require js it looks like this 'Vendor_CustomCustomer/js/form/element/customercustom': true ? – fmsthird May 3 at 10:25
  • Yes, it looks like this. – Meetali Gupta May 3 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.