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
Post a Comment