In Mootools, the value of the this variable within a function can be controlled:
function foo() {
// do something with the this variable
}
var bar = foo.bind(some_object);
// Now bar does the same thing as foo, except
// the this variable is a reference to some_object
Can this be done in Jquery?
jQuery offers the
.proxy()method. It basically does the same as.apply()or.call()and it’s syntax looks like:In your example it would be:
Ref.: .proxy()