javascript - I want to call parent function into function which is wraped in object -


below code -

     contactnumbermask: function(value) {        return value      },       componentdidmount: function() {        this.params = {           cellnumber: ''        };        var masklist =  $.maskssort($.masksload("http://cdn.rawgit.com/andr-04/inputmask-multi/master/data/phone-codes.json"), ['#'], /[0-9]|#/, "mask");         this.maskopts = {           inputmask: {               onmaskchange: function(maskobj, determined) {                 if (determined) {                 var number = this.contactnumbermask(maskobj.mask);                 this.params.cellnumber = number+'-'+this.params.cellnumber;             }         }     }; }, 

in want call this.contactnumbermask() function inside onmaskchange() function. not getting reference of this.

use bind() set context

        onmaskchange: function(maskobj, determined) {             if (determined) {             var number = this.contactnumbermask(maskobj.mask);             this.params.cellnumber = number+'-'+this.params.cellnumber;         }.bind(this) 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -