>To get around it, I've added the following to run on every page of the site:
>jQuery('a').click(function(){document.location.href=this.href});
>I don't like this very much - it feels a little dangerous for reasons I can't
>put my finger on.
The reason your gut is saying this is a dangerous is twofold:
1. It doesn't respect preventDefault() meaning that it could break other event
handlers for hijaxing, etc you might be depending on or adding later. This
makes the tests brittle.
//FIX: check isDefaultPrevented
jQuery('a').click(function(e){
If(!e.isDefaultPrevented()) { //check for default prevented
first
document.location.href=this.href;
}
});
2. It is contingent on the order of added event handlers and breaks any event
handlers added after you add it.
//ALMOST FIX: event delegation
jQuery(document).delegate('a', 'click', function(e){
If(!e.isDefaultPrevented()) { //check for default prevented
first
document.location.href=this.href;
}
});
This is just an almost fix because now you are depending on the order of event
delegation which you may not control making this solution brittle as well.
Unfortunately, I'm not sure I know of a solution, but hopefully this helps
explain your gut reaction :-]
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]