Skip to content

$.proxy missing arguments #882

noelboss opened this Issue Dec 11, 2013 · 2 comments

3 participants


I wanted to make my jQuery Plugin Zepot-Capable. I use proxy frequently and jQuery supports arguments to be forwarded to a proxied method;

jQuery.proxy( function, context [, additionalArguments ] )

Zepto doesn't.

mislav commented Dec 11, 2013

Thanks for reporting! We'll try to add that.

@wiebl wiebl pushed a commit to wiebl/zepto that referenced this issue Jan 5, 2014
Michiel van Roon $.proxy now accepts arguments. Fixes #882
Example: $.proxy(myFunction, myClass, argument1, argument2)

Tested on Chrome and Firefox using the following code:

var ContextTest = function() {},
    say = function(message1, message2, message3) {
    console.log('context should be ContextTest:', this, 'first argument:', message1, 'second argument:', message2, 'third argument:', message3);
newContextTest = new ContextTest()

$(document).on('ready', $.proxy(say, newContextTest, 'this is the first argument', 'this is the second argument', 'this is the third argument'));
wiebl commented Jan 5, 2014

since $.proxy returns a function, you could supply arguments like this:
$.proxy(function, context)(arg1, arg2, arg3)
Now you can also put the arguments inside the call:
$.proxy( function, context [, additionalArguments ] )
Which is more consistent with jQuery. However using both methods together will result in $.proxy only using the arguments you supplied in the call, is this acceptable?
$.proxy(function, context, arg1, arg2)(arg3, arg4) only uses arg1 and arg2

@mislav mislav added a commit that closed this issue Jul 7, 2014
Michiel van Roon `$.proxy` now accepts additional arguments

  var fn = $.proxy(myFunction, contextObject, argument1, argument2)

Fixes #882
@mislav mislav closed this in 5704657 Jul 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.