원래의 코드를 바인딩 :jQuery를 :하여 addEventListener에서 전환
this.control.addEventListener('click', $.proxy(function() {
this.time.hashours = (this.duration()/3600) >= 1.0;
this.time.duration.text(getTime(this.duration(), this.controls.time.hasHours));
this.time.current.text(getTime(0, this.controls.time.hasHours));
}, this));
크로스 브라우저 지원에서 시도 : 심지어 프록시
이$(this.control).bind('click', $.proxy(function(e) {
var o = e.delegateTarget;
o.time.hashours = (o.duration()/3600) >= 1.0;
o.time.duration.text(getTime(o.duration(), o.controls.time.hasHours));
o.time.current.text(getTime(0, o.controls.time.hasHours));
}, this));
이의 상황이 더 이상에 속하는 없다 jQuery의 커스텀 이벤트 모델 때문에 객체를 호출한다. 원본 this.control
을 얻으려면 어떻게해야합니까?
당신 말이 맞아요. '.bind' 대신'.on'을 사용하면'$ .proxy'와 함께 작동합니다. –
@BrianGraham -'bind'와'on'은이 특별한 예제에서 기능적인 차이점이 없습니다. 아마 그 실수를 일으키는 다른 것이었을 것입니다. – Anurag