• Resolved jarth3000

    (@jarth3000)


    Hello!

    I wanted to thank you again for helping with my previous issue, but now, another has arisen.

    The posts that Ajax Load More are loading have a link in them in which when clicked, it pulls up a div and loads content via ajax. This works for my initial posts, but not for the posts that are pulled via Ajax Load More. I suspect it has to do with the jquery calls and loads prior to Ajax Load More bringing in more posts.

    I’m assuming it’ll be a simple fix of adding something to the jQuery file of Ajax Load More, but I figured I’d ask the creator for assistance so I don’t muck it up.

    Below is the ajax call that when a link is click, it pulls the additional info.

    $.ajaxSetup({cache:false});
            $(".more-results").click(function(){
                 var post_link = $(this).attr("href");
     	    $('#results-overview').fadeIn('slow');
                $("#results-overview").load(post_link);
    	    $(document).click(function(event) {
        		if(!$(event.target).closest('#results-post').length) {
            		if($('#results-post').is(":visible")) {
                			$('#results-overview').fadeOut('slow');
            		}
        		}
    		})
    	    $(document).ajaxComplete(function() {
    
      		$('#scrollbox3').enscroll({
        			showOnHover: true,
        			verticalTrackClass: 'track3',
        			verticalHandleClass: 'handle3'
    			});
    	$("#vote").click(function(){
        		$(this).fadeOut('slow');
    		$('#vote-ratings').fadeIn('slow');
    	});
    
    		});
    
            return false;
            });

    As I’ve said, the code works on the initial items pulled by my main loop, but NOT the ones pulled by Ajax Load More.

    Thoughts?

    Thanks!

    Josh

    https://wordpress.org/plugins/ajax-load-more/

Viewing 1 replies (of 1 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi,
    you likely need to move your click events to use jQuery on(). THe issue is you have click events on elements that are not yet created.

    Like so,

    $(document).on('click', '.more-results', function(){
    });
    $(document).on('click', '#vote', function(){
       $(this).fadeOut('slow');
       $('#vote-ratings').fadeIn('slow');
    });

    http://api.jquery.com/on/

Viewing 1 replies (of 1 total)

The topic ‘Ajax Issue’ is closed to new replies.