Forget about that immediatly! I checked for e in the callback of a 
load() function which causes that strange behaviour...

Seems to be a closure problem: The parameter of the outer function gets 
not into the scope of the inner closure, which I thought it would do:


$(this).click(function(e) {
     $(this).load(url, function() {

         // where's e?

     });
});

Can somebody explain that to me?

I can get away with:

$(this).click(function(e) {
     var trueClick = e.clientX;
     $(this).load(url, function() {

         // trueClick is here of course...

     });
});


-- Klaus


Klaus Hartl schrieb:
> Hi all,
> 
> here's a problem I don't understand. I'm currentlx fixing my 
> history/remote plugin for IE and what I need to do is adding to history 
> only if a true click ocurred and not a triggered one. That works quite 
> good by checking e.clientX.
> 
> But in IE I found some strange behaviour, or I just don't understand:
> 
> $.fn.remote = function(output) {
>      ...
>      return this.each(function(i) {
>          ...
>          $(this).click(function(e) {
> 
> 
>          });
>      });
> };
> 
> Now in the click handler function
> 
> * in case of a triggered click everything's seems correct:
> window.event is null
> e.clientX is undefined
> 
> * but in case of a true click I get this:
> window.event is still null => ?
> typeof e.clientX is "unknown" => ?
> 
> And then, even better: if I chain click() instead of using $(this) in 
> the each loop (I did that to have a variable at hand in the click 
> handler) I get what I expect for a true click:
> 
> $.fn.remote = function(output) {
>      ...
>      return this.each(function(i) {
>          ...
>      }).click(function(e) {
> 
>      });
> };
> 
> window.event is not null
> typeof e.clientX is a number
> 
> I'm using the latest revision of jQuery, but the same bug occurs in 1.03 
> and 1.01. Can anyone clarify?
> 
> 
> -- Klaus
> 
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
> 


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to