jQuery $.proxy() 메서드

❮ jQuery 이벤트 메소드

예시

objPerson 내부에서 "test" 함수의 컨텍스트를 적용합니다.

$("button").click($.proxy(objPerson, "test"));

정의 및 사용

$.proxy 메서드는 기존 함수를 사용하고 특정 컨텍스트가 있는 새 함수를 반환합니다.

이 메서드는 컨텍스트가 다른 개체를 다시 가리키는 요소에 이벤트를 첨부하는 데 자주 사용됩니다.

팁: $.proxy에서 반환된 함수를 바인딩하는 경우 jQuery는 원본을 전달한 경우 올바른 함수를 여전히 바인딩 해제합니다.


구문 1

$(selector).proxy(function,context)

구문 2

$(selector).proxy(context,name)

Parameter Description
function The existing function to be called
context The name of the object where the function lies
name The existing function whose context will be changed (should be a property of the context object).

❮ jQuery 이벤트 메소드