Search code examples
javascriptjquerylivequery

livequery stopped working


$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>

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>