2014-06-17 2 views
0

어떻게 이벤트를 _.throttle 함수에 전달할 수 있습니까? 이 함수를 실행시키는 요소의 id를 전달해야합니다.jQuery 'on'함수를 사용하여 _.throttle 함수에 이벤트 전달

function aaa (id) { 
    console.log(id); 
} 


jQuery('#inputStreet').on('input', _.throttle(aaa(event.target.id), 2000)); 

콘솔은이 정의되지 않은 재산 '대상'을 읽을 수 있다고 말한다 :이 코드 예제입니다.

답변

1

당신은 _.throttle에게 함수가 아닌 결과 함수 호출의을 통과해야합니다.

jQuery('#inputStreet').on('input', _.throttle(function(event){ 
    aaa(event.target.id); 
}, 2000));