admin管理员组

文章数量:1277875

I'm using jQuery with the bxSlider plugin, here is the link to it just incase: /

I'm trying to reload the slider and my custom pager after I've removed certain slides from it.

Here is what I have tried:

$(function() {
    var slider = $('#slider').bxSlider({
        pagerCustom: '#bx-pager'
    });

    $('.list').on('click', '.delete', function() {
        image = $(this).closest('li').find('[type="hidden"]');

        // image.attr('id') contains a string: image-0, image-1, image-2, etc.
        $('#slider, #bx-pager').find('.' + image.attr('id')).remove(); 

        slider.reloadSlider({
            pagerCustom: '#bx-pager'
        }); // I have also tried: slider.reloadSlider();
    });
});

It works partially. What happens is the slider gets reloaded just fine but it removes the pager pletely when it runs the reload.

Thank you very much for any help.

I'm using jQuery with the bxSlider plugin, here is the link to it just incase: http://bxslider./

I'm trying to reload the slider and my custom pager after I've removed certain slides from it.

Here is what I have tried:

$(function() {
    var slider = $('#slider').bxSlider({
        pagerCustom: '#bx-pager'
    });

    $('.list').on('click', '.delete', function() {
        image = $(this).closest('li').find('[type="hidden"]');

        // image.attr('id') contains a string: image-0, image-1, image-2, etc.
        $('#slider, #bx-pager').find('.' + image.attr('id')).remove(); 

        slider.reloadSlider({
            pagerCustom: '#bx-pager'
        }); // I have also tried: slider.reloadSlider();
    });
});

It works partially. What happens is the slider gets reloaded just fine but it removes the pager pletely when it runs the reload.

Thank you very much for any help.

Share Improve this question asked Aug 1, 2013 at 8:05 adamjadamj 4,7926 gold badges51 silver badges60 bronze badges 1
  • Same issue here. Have you found any solution? – Michele Gargiulo Commented Aug 9, 2013 at 8:53
Add a ment  | 

1 Answer 1

Reset to default 11

As long as I see, this is a bug in bxSlider, in fact, when you call the reloadSlider method, internally are called the methods destroySlider and init.

In the destroySlider method the pagerEl element is destroyed, this is right if you are not using a custom one, because it is recreated programmatically in the init method, but if you are using a custom one it can't be recreated programmatically.

I ended up modifying the destroySlider method to check if a custom pager is used, in this case it must not be deleted.

Here is the before (line 1294):

if(slider.pagerEl) slider.pagerEl.remove();

And after:

if (slider.settings.pagerCustom === '') {
    if(slider.pagerEl) slider.pagerEl.remove();
}

I'll post the bug on GitHub as soon as I have the time.

本文标签: javascriptjQuerybxSlider plugin reloadSlider issuesStack Overflow