$.proxy() - passing scope into functions
Found this great little function a couple of days ago. The jquery docs have a lot of stuff in them so i’m not gonna copy any of that - you can find them here.
In simple terms it’s used to pass a specific scope into a function so ‘this’ get’s over written with that scope.
I found it was VERY useful when using jquery ajax calls in another object - the ‘this’ in the success event on the ajax call would be in the scope of the jquery function but it’s more useful having ‘this’ being related to the parent function.
The answer is to use the proxy function to overwrite the ‘this’ object in the resulting function code and pass all actions on that object to it’s parent.