2013-07-11 5 views
1

터치 장치의 경우 touchstarttouchmove에 대한 몇 가지 이벤트 리스너가 있습니다. 다른 모든 jQuery를 구속 이벤트가 있지만,이 자바 스크립트를 사용하여 결합되도록 어떤 이유로이 터치 이벤트를 작동하지 않았다 :backbone.js의 javascript 이벤트 리스너에서 가져 오기

document.addEventListener('touchstart', this.touchstart); 
document.addEventListener('touchmove', this.touchmove); 

이 가진 문제는 내가에서 이벤트를 트리거 할 때 jQuery를 이벤트를 바인딩, 난 그냥 예를 들어, 사용할 수 있습니다

this.scrollContainer(); 

그러나 this의 맥락 나는 경우이 방법을 트리거 할 수 없음을 의미 자바 스크립트 바운드 이벤트 내에서 다르다.

제 질문은 자바 스크립트 바인딩 이벤트에서이 이벤트를 트리거 할 수 있습니까? 그렇다면 어떻게?

답변

2

당신은 콜백

document.addEventListener('touchstart', _.bind(this.touchstart, this)); 
document.addEventListener('touchmove', _.bind(this.touchmove, this)); 
에 사용자 정의 컨텍스트를 전달하는 _.bind()를 사용할 필요가
관련 문제