I think anonymous functions are much easier to read and understand. They also make scoping a bit cleaner. You can rewrite with named functions if it makes sense for your application. This is untested, but should be close to what you're asking:
jQuery( '#myButton' ).bind( 'click', function() { var theButton = this; jQuery.getJSON( url, null, function( json ) { // handle json stuff here. theButton is the DOM node of the clicked element. // or call handleResult(json, theButton); to pass the element to handleResult } );}); FYI, if this is your real code, this: jQuery.getJSON( url, null, function( json ) { myProject.handleResult( json ) } ); Is the same as this: jQuery.getJSON( url, null, myProject.handleResult ); Creating an anonymous function that just calls a function with the same arguments is redundant. This probably isn't actually what you want in this case though since you then can't pass the button reference. --Erik On Fri, Dec 5, 2008 at 2:16 AM, pramodx <[EMAIL PROTECTED]> wrote: > > Hi, > > On click of a button I am placing a json call in the following manner > > jQuery( '#myButton' ).bind( 'click', myProject.callJson ); > > The callJson function calls the json parameters: > > jQuery.getJSON( url, null, function( json ) { myProject.handleResult > ( json ) } ); > > The handleResult function further takes me to someOtherFunction() as > well. > > The issue is that all the while I need to keep on passing a reference > to the clicked button through jQuery(this) so that I can manipulate it > in someOtherFunction(). How do I do that? Any pointers would be very > helpful. > > Thanks > Pramod >