How to use "arguments" object in jquery function like 'this'?

I need to use a parameter arguments

in a jQuery function as my own element and not as the default element. My code: I have to name the main superclass in $(window).load

:

 MyController.__super__.scroll.apply(this, arguments);

      

I am doing something like this:

 var context = this;
 var contextArgs= arguments;
 $(window).load(
   function(){
   MyController.__super__.scroll.apply(context , contextArgs);  //call backbone superclass
 });

      

I don't want to create new param 'context' and 'contextArgs'. I can only prevent var context = this; using Jquery.proxy:

 var contextArgs= arguments;
 $(window).load(
     $.proxy(function() {
         MyController.__super__.scroll.apply(this , contextArgs);
     },this)
 );

      

How to prevent another parameter from being created var contextArgs= arguments;

+3


source to share


1 answer


You can pass other arguments to proxy

, and they will be available as arguments to the function:



$(window).load(
    $.proxy(function(contextArgs){
        MyController.__super__.scroll.apply(this , contextArgs);
    },this, arguments)
);

      

+3


source







All Articles