You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update $.proxy to show signatures w/ additional args
* Refers to jquery#80. Not closing until reviewed.
* Note: Use of "slash-star" comments is necessary because
of the way we convert code in html to demos.
<desc>Any number of arguments to be passed to the function named in the <code>name</code> argument.</desc>
44
+
</argument>
45
+
</signature>
46
+
22
47
<desc>Takes a function and returns a new one that will always have a particular context.</desc>
23
48
<longdesc>
24
49
<p>This method is most useful for attaching event handlers to an element where the context is pointing back to a different object. Additionally, jQuery makes sure that even if you bind the function returned from <code>jQuery.proxy()</code> it will still unbind the correct function if passed the original.</p>
25
50
<p>Be aware, however, that jQuery's event binding subsystem assigns a unique id to each event handling function in order to track it when it is used to specify the function to be unbound. The function represented by <code>jQuery.proxy()</code> is seen as a single function by the event subsystem, even when it is used to bind different contexts. To avoid unbinding the wrong handler, use a unique event namespace for binding and unbinding (e.g., <code>"click.myproxy1"</code>) rather than specifying the proxied function during unbinding.
26
51
</p>
52
+
<p><strong>As of jQuery 1.6</strong>, any number of additional arguments may supplied to <code>$.proxy()</code>, and they will be passed to the function whose context will be changed.</p>
27
53
</longdesc>
28
54
<example>
29
55
<desc>Change the context of functions bound to a click handler using the "function, context" signature. Unbind the first handler after first click.</desc>
@@ -35,13 +61,13 @@
35
61
var me = {
36
62
type: "zombie",
37
63
test: function(event) {
38
-
// Without proxy, `this` would refer to the event target
39
-
// use event.target to reference that element.
64
+
/* Without proxy, `this` would refer to the event target */
65
+
/* use event.target to reference that element. */
40
66
var element = event.target;
41
67
$(element).css("background-color", "red");
42
68
43
-
// With proxy, `this` refers to the me object encapsulating
44
-
// this function.
69
+
/* With proxy, `this` refers to the me object encapsulating */
0 commit comments