0

I need quick help regarding calling a function within a function using Magento knockout js, I have tried this

define([
    'ko',
    'uiComponent'
], function (ko, Component) {
    'use strict';

    return Component.extend({
        initialize: function () {
            //initialize parent Component
            this._super();
        },

        testfunctionout: function() {
        var self = this;
            console.log(' in testfunctionout');
        self.testfunctionin();
        },

        testfunctionin: function() {
            console.log(' in testfunctionin');
        }

    });
});

Can anyone help me out? Thanks in advance.

  • What error you got in console? Did you called testfunctionout function? – Ranganathan Oct 15 '19 at 6:53
0

use self under initailize function dont declare it under testfunctionOut

 initialize: function () {
            self = this;
 }
 testfunctionout: function() {
        console.log(' in testfunctionout');
    self.testfunctionin();
    },

    testfunctionin: function() {
        console.log(' in testfunctionin');
    }
|improve this answer|||||
0

Try this:

define([
    'ko',
    'uiComponent'
], function (ko, Component) {
    'use strict';

    return Component.extend({
        initialize: function () {
            //initialize parent Component
            var self = this;
            this._super();
        },

        testfunctionout: function() {
            console.log('in testfunctionout');
            this.testfunctionin();
        },

        testfunctionin: function() {
            console.log(' in testfunctionin');
        }

    });
});
|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.