I think this is due to the fact that no context is passed in to the .load() callback, in that manner. I think doing something like this would work:
$(document).ready(function(){ $("p").each(function(){ $(this).load("ajax.php", function(){ $("a",this).click(function(){ alert("The link is overridden."); return false; }); }); }); }); That way, only the links directly within the paragraph will be overridden. --John On 3/2/07, Søren Haagerup <[EMAIL PROTECTED]> wrote: > > Hi everyone, > > I have got some trouble getting this snippet of code working in newer > versions of jQuery: > > $(document).ready(function(){ > $("p").each(function(){ > $(this).load("ajax.php", function(context){ > $("a",context).click(function(){ > alert("The link is overridden."); > return false; > }); > }); > }); > }); > > ajax.asp contains the link, and the site itself contains a <p>. > > The code above for overriding a link only works well in jQuery 1.1.2 if I > - take away the context-limitation. But that makes it unstable when using it > on pages with many links (both in old and new versions of jQuery) > - don't load the links with Ajax -- but I need that. > > Everything is fine in the old one. > > v1.0.4: http://gawis.dk/jquery-testbed/overridelinks/ > v1.1.2: http://gawis.dk/jquery-testbed/overridelinks/?ver=new > > Any ideas about what's wrong in 1.1.2 and how to overcome it, or do I just > have to stay with the "old" jQuery 1.0.4 ? > -- > View this message in context: > http://www.nabble.com/Bug-when-overriding-links-within-specific-context%2C-using-jQuery-1.1.*--tf3333905.html#a9270505 > Sent from the JQuery mailing list archive at Nabble.com. > > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/