This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Issue with Lazy Loading of images

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Issue with Lazy Loading of images Reply To: Issue with Lazy Loading of images

#25212
Ernest MarcinkoErnest Marcinko
Keymaster

Instead of that, maybe using a mutation observer method could be much better. In your case something like this:

jQuery(function($) {
  // The node to be monitored
  var target = "#primary";
  var t;
  
  if ( jQuery(target).length > 0 ) {
    target = jQuery(target).get(0);
    // Create an observer instance
    var observer = new MutationObserver(function( mutations ) {
      mutations.forEach(function( mutation ) {
        var newNodes = mutation.addedNodes; // DOM NodeList
        if( newNodes !== null ) { // If there are new nodes added
            // Execute your code here!
            console.log('New nodes are added!');
            clearTimeout(t);
            t = setTimeout(function(){
              $(window).scroll();
              $(document).scroll();
            }, 250);
           	if( $('.close-sidebar').length ){
                $('.close-sidebar').click();
            }
        }
      });    
    });
    
    // Configuration of the observer:
    var config = { 
    	attributes: true, 
    	childList: true, 
    	characterData: true 
    };
     
    // Pass in the target node, as well as the observer options
    observer.observe(target, config);
  }
});

This should be much better, as it does not use events, but it works a bit differently.

I cannot guarantee that either of these work in any way unfortunately. I will add an event hanlder for when the live results are finished for the upcoming release. (asp_search_end)