0
votes

enter image description hereHow to call the function when click on button. I created the button and print (hello on console). It will print but when I define the function for simple addition of two number then it gives error.

I used the following code:

var FormCustomControllerMixin = {
   init: function (parent, model, renderer, params) {
       this.importEnabled = params.importEnabled;
   },

   _getLocation : function(){
       var a=10;
       var b=20;
       var c= a+b;
       console.log(c);
   },

   _bindImport: function () {
       if (!this.$buttons) {
           return;
       }
       var self = this;
       this.$buttons.on('click', '.o_button_custom_form', function () {
           console.log('Hello');
           a=self._getLocation();
         console.log(a);
       });
   }
};

Hello is print but addition is not perform.

2
Where are these errors ?Kenly
I edit my question please see the edit one.@Zetyuser_123
Still not working...user_123
it's not giving you that the _getlocation does not exist but what is the value of location check what is the value by just using console.log(self.__getlocation)Charif DZ

2 Answers

0
votes

Have you tried like this?

a=_getLocation();
0
votes

I gotted the solution getlocation function does not work inside FormCustomCOntrollerMixin.

var a = function getLocation () {
        var a=10;
        var b=20;
        var c= a+b;
        console.log(c);
        return
    }



var FormCustomControllerMixin = {

    init: function (parent, model, renderer, params) {
        this.importEnabled = params.importEnabled;
    }
    },

    _bindImport: function () {
        if (!this.$buttons) {
            return;
        }
        var self = this;
        debugger;
        this.$buttons.on('click', '.o_button_custom_form', function () {
            var b = a();

        });
    }
};