jQuery $.proxy() Yöntemi

❮ jQuery Olay Yöntemleri

Örnek

objPerson içinde "test" işlevinin bağlamını uygulayın:

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

Tanım ve Kullanım

$.proxy yöntemi, mevcut bir işlevi alır ve belirli bir bağlamla yeni bir işlev döndürür.

Bu yöntem genellikle, bağlamın farklı bir nesneye işaret ettiği bir öğeye olayları eklemek için kullanılır.

İpucu: $.proxy'den döndürülen işlevi bağlarsanız, jQuery, orijinali geçerse yine de doğru işlevi çözecektir.


sözdizimi 1

$(selector).proxy(function,context)

sözdizimi 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 Olay Yöntemleri