JQuery delegate what may cause it to not function
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?
EDIT: heres the list of other scripts on the page:
<script type="text/javascript" src="/Scripts/jquery-1.4.2.js"></script>
<script type="text/javascript" src="/Scripts/2010.1.416/telerik.common.min.js"> </script>
<script type="text/javascript" src="/Scripts/2010.1.416/telerik.textbox.min.js"></script>
<script type="text/javascript" src="/Scripts/2010.1.416/telerik.grid.js"></script>
<script type="text/javascript" src="/Scripts/2010.1.416/telerik.grid.filtering.min.js"></script>
<script type="text/javascript" src="/Scripts/2010.1.416/jquery.validate.min.js"></script>
<script type="text/javascript" src="/Scripts/2010.1.416/telerik.grid.editing.min.js"></script>
It appears as the toolset I was using, Telerik ASP.NET MVC controls 2010.1.416 had a reference to jquery.validate.min.js
The version of the file they ship is 1.5.5
Updating this version to 1.7 and delegate is again working as expected.
/smack.
精彩评论