2

I am using 2 components for multi-select and select input fields.

Multiselect component -

define([
    'underscore',
    'uiRegistry',
    'Magento_Ui/js/form/element/multiselect',
    'Magento_Ui/js/modal/modal',
    'Namespace_Modulename/js/selectoptions'
], function (_, uiRegistry, multiselect, modal,selectoptions) {
    'use strict';

    return multiselect.extend({

        /**
         * On value change handler.
         *
         * @param {String} value
         */
        onUpdate: function (value) {
            console.log(selectoptions.myNew());
            return this._super();
        },
    });
});

Select Component -

define([
    'underscore',
    'uiRegistry',
    'Magento_Ui/js/form/element/select',
    'Magento_Ui/js/modal/modal'
], function (_, uiRegistry, select, modal) {
    'use strict';

    return select.extend({

        myNew: function () {
            console.log('In my new function');
        },
    });
});

I have injected selectoptions component in multi-select component and calling its myNew method onUpdate of multi-select. But I am getting below error.

selectoptions.myNew is not a function

UPDATE

I was able to call the function now using

selectoptions.prototype.myNew();

But still not getting why we need to use prototype here.

| improve this question | | | | |
  • Are you solve this? – Mahi M Aug 19 '19 at 11:35
0

try call the function use

selectoptions().myNew();
| improve this answer | | | | |

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.