Passing a function with arguments as an argument?

arguments, closures, function, javascript, parameters

Solution

Use a "closure":

$(edit_link).click(function(){ return changeViewMode(myvar); });

This creates an anonymous temporary function wrapper that knows about the parameter and passes it to the actual callback implementation.

Problem

Is it possible to pass a javascript function with arguments as an argument? Example: ``` $(edit_link).click( changeViewMode( myvar ) ); ```

Original source

Related problems