I'd like to point out here that you don't really need to place this variable
inside the jQuery namespace, you don't even need to enable it to get out of
its scope by making it global, so you may do something like that :

$(this).bind("click", function(e) {
var temp =  $(this); // this is a local variable, outside the scope of the
function where it's declared it isn't registered anymore
$.get("main.php?action=getEventDetails",},function(data) {
temp.html(data); // though this anonymous function used as call back has
been declare in the scope of temp's holding function, therefore temp is
still declared and still holding the reference to former $(this)
});
});

And it will still work, temp stays declared as long as the callback needs
it, but it doesn't get out from your click callback so no pollution of any
namespace or outer scope.

Michel Belleville


2009/11/25 coffeecup <gocoffee...@gmail.com>

> thanks, i registered a $.temp var outside of my get function and now
> it works!
>
> $.temp = {};
>
>
>
>  $(this).bind("click", function(e){
>       $.temp =  $(this);
>      $.get("main.php?action=getEventDetails",},function(data){
>          $.temp.html(data);
>      });
>  });
>
>

Reply via email to