JQuery delegate what may cause it to not function
        Posted  
        
            by Jafin
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Jafin
        
        
        
        Published on 2010-04-23T05:20:43Z
        Indexed on 
            2010/04/23
            5:23 UTC
        
        
        Read the original article
        Hit count: 299
        
jQuery
I have a webpage using jquery 1.42
The following 2 segments of code live in my page.
$('body').delegate('h2', 'click', function() {
    $(this).after("<p>delegate paragraph!<\/p>");
});
$('body h2').live('click', function() {
    $(this).after("<p>live paragraph!<\/p>");
});
The live method always works, yet the delegate doesn't fire at all.
If I create a trivial page with simple html
<body><h2>blah</h2></body>  
both approaches work. So I'm assuming there is something else going on in my page.
With firebug I am seeing no javascript errors, no html errors. and breakpoints on the delegate method definately do not get hit.
What else might be the cause of delegate not triggering?
© Stack Overflow or respective owner