Accessing $ (this) in a callback function
I am working on changing prompt () to jPrompt () since IE is blocking the prompt () function. The problem is that $ (this) no longer works correctly because jPrompt () does not return a value, but uses a callback function.
So, let's say I have something like this that works:
$("a.foo").click(function(){
$(this).text(prompt("Type Something",""));
}
When I convert it to this it breaks:
$("a.foo").click(function(){
jPrompt("Type something:","","", function(r) {
$(this).text(r);
}
}
How do I get $ (this) correctly?
+1
source to share