jQuery API - triggerHandler/ toggle/ proxy/ delegate/

Posted by 단순대왕 jQuery : 2014. 7. 16. 16:38

.triggerHandler()

.triggerHandler( eventType [, extraParameters ] ) Returns: Object

Description: Execute all handlers attached to an element for an event.

The .triggerHandler() method behaves similarly to .trigger(), with the following exceptions: [더보기]


.toggle()

.toggle( [duration ] [, complete ] ) Returns: jQuery

Description: Display or hide the matched elements.


다른 예제] 클릭할 때마다 두 개의 다른 리스너를 바꿔가며 호출

$('#test').toggle(

function(event){ alert("on"); },

function(event){  alert("off"); }

);


$.proxy()

Description: Takes a function and returns a new one that will always have a particular context.

jQuery.proxy( function, context ) Returns: Function

jQuery.proxy( context, function_name ) Returns: Function


.delegate()

.delegate( selector, eventType, handler ) Returns: jQuery

.delegate( selector, eventType, eventData, handler )

Description: Attach a handler to one or more events for all elements that match the selector, 

now or in the future, based on a specific set of root elements.


.delegate() has been superseded by the .on() method. For earlier versions, 

however, it remains the most effective means to use event delegation. 

More information on event binding and delegation is in the .on() method. 

예)

$( "table" ).delegate( "td", "click", function() {

$( this ).toggleClass( "chosen" );

});

is equivalent to the following code written using .on():

$( "table" ).on( "click", "td", function() {

$( this ).toggleClass( "chosen" );

});

'jQuery' 카테고리의 다른 글

jQuery Ajax Sample  (0) 2014.07.17
jQuery Ajax 사용하기  (0) 2014.07.17
jQuery 확장 메소드 만들기  (0) 2014.07.16
jQuery Deprecated API  (0) 2014.07.15
jQuery 사용자 정의 함수 만들기  (0) 2014.07.15