Newbie
Newbie

Reputation: 69

jquery. livequery() strange behavior

trying to run jquery plugin "livequery" to highlight some words in a dynamically generated search results doesn't work ! However adding an alert() function before excuting the code make the highlighting appear! so what is the problem?

$(document).ready(function(){     
     $('#searchResults').livequery(function(el){
     // alert('test');
     $( '#searchResults' ).highlight( highlightArray );
 });
});  

Upvotes: 0

Views: 98

Answers (2)

Lelio Faieta
Lelio Faieta

Reputation: 6669

Why do you still use livequery? It is not necessary by now. It was before jQuery delegated events. See this SO answer for more informations. Use .on() instead of livequery().

So you can just do

$(document).on('change','#searchResults',function(el){
    $('#searchResults').highlight(highlightArray);
});

Upvotes: 1

vijayP
vijayP

Reputation: 11502

Can you try adding some delay by setTimeout()

$(document).ready(function(){     
     $('#searchResults').livequery(function(el){
         // alert('test');
         setTimeout(function(){
             $( '#searchResults' ).highlight( highlightArray );
         },400);
     });
});  

Upvotes: 1

Related Questions