jQuery的delegate()与proxy()方法

1. 

jQuery 事件 - delegate() 方法

定义和用法

delegate() 方法为指定的元素(属于被选元素的子元素)添加一个或多个事件处理程序,并规定当这些事件发生时运行的函数。

使用 delegate() 方法的事件处理程序适用于当前或未来的元素(比如由脚本创建的新元素)

$("div").delegate("button","click",function(){
  $("p").slideToggle();
});

www.w3school.com.cn/jquery/event_delegate.asp

2. 

The $.proxy method takes an existing function and returns a new one with a particular context.

This method is often used for attaching events to an element where the context is pointing back to a different object.

Tip: If you bind the function returned from $.proxy, jQuery will still unbind the correct function if passed the original. 

http://www.w3schools.com/jquery/event_proxy.asp

----

this.$el.delegate('tbody tr', 'click', $.proxy(this._clickRow, this));
原文地址:https://www.cnblogs.com/simoncook/p/4852967.html