Lightbox Does Not Work After Loading Page 2 or Later in autopager.js

Asked 2 years ago, Updated 2 years ago, 95 views

<div class="contents">
<?php if(have_posts()):while(have_posts()):the_post();?>

<div class="post"></div>
<div class="post"></div>
<div class="post"></div>
<div class="post"></div>

<?php endwhile;?>

</div>

<div class="ajaxLoad">
<?php next_posts_link('more');?>
</div>

<script>
$(function(){
    $.autopager({
        content: '.post',
        link: '.ajaxLoad a',
        autoLoad: false,
        load:function(current, next){
            if(current.page>=<?phpecho$wp_query->max_num_pages;?>){$('.ajaxLoad').hide();}
        }
    });
    $('.ajaxLoad a').click(function(){
        $.autopager('load');
        return false;
    });
});

I use the WordPress plug-in wp-jquery-lightbox
I use jquery-autopager for pageation, but
lightbox will no longer work after page 2
May I ask you?

jquery wordpress

2022-09-29 22:13

1 Answers

I think the reason is that there is no lightbox event on the dom read by ajax.
Therefore, it should be activated by re-addling the lightbox after loading dom.

However, I am not familiar with autopager and lightbox, so please check the library separately to determine after loading ajax and run the lightbox.

Maybe it works below...

$.autopager({
        ......
        load:function(current, next){
            ......
            doLightBox()
        }
    });


2022-09-29 22:13

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.