Question

$j(".context-menu").livequery(function(){
    alert('found');
});

This was working until a couple of days ago. It just suddenly stopped. On addition of new elements with class 'context-menu' nothing happens.

Although in firebug if I run the above statement, its found and an alert is thrown.

Any idea what the problem could be ?

HTML:

<html>
<head>
    <script type='text/javascript' src='/scripts/prototype.js'></script>
    <script type='text/javascript' src='/scripts/jquery-1.4.2.js'></script>
    <script type='text/javascript'>
    var $j = jQuery.noConflict();
    </script>
    <script type='text/javascript' src='/scripts/jquery.livequery.js'></script>
</head>
<body>
    <div class='fun'>fun</div>
</body>
Was it helpful?

Solution

I created this simple snippet to test if livequery works with current jQuery and it does with no problem (here's the jsfidde http://jsfiddle.net/x3tds/1/):

<a href="javascript:void(0)" onclick="adddiv('')">Click me</a>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

<script src="http://brandonaaron.net/javascripts/plugins/livequery.js"></script>


<script>

jQuery("div").livequery(function() { alert("div added") })

function adddiv()
{
    jQuery("a").append("<div>Hello</div>")
}
</script>

OTHER TIPS

Did you update any of your other Javascript code? It seems like you have a syntax error or something in the rest of your Javascript which would mean that everything (including this part) fails.

Run your site with the Firebug error console active and make sure it catches Javascript errors and warnings by checking your settings (the arrow in the console tab).

Did you recently upgrade to jQuery 1.4.2? I don't think the livequery plugin is fully compatible with jQuery 1.4+

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top