Overwritten “this” variable problem or how to call a member function?

前端 未结 4 1265
小鲜肉
小鲜肉 2020-12-21 23:16

I have this class where I am using a combination of jQuery and Prototype:

var MyClass = Class.create({
    initElements: function(sumEl) {
       this.sumEl          


        
4条回答
  •  佛祖请我去吃肉
    2020-12-22 00:00

    You need to use closures.

     initElements: function(sumEl) {
            this.sumEl = sumEl;
            var ref = this;
            sumEl.keyup( function(){ref.updateSumHandler();});
     },
    

提交回复
热议问题