CSS-Tricks / AnythingSlider

A jQuery Slider plugin for anything.
http://css-tricks.github.io/AnythingSlider/
GNU Lesser General Public License v3.0
1.15k stars 380 forks source link

anythingSlider with colorbox problem in the panel if not activePage #423

Closed claudchan closed 12 years ago

claudchan commented 12 years ago

Hi, Not sure if anyone encounter this. I am using [ showMultiple: 2, changeBy: 1, infiniteSlides: true, stopAtEnd: false ] in anythingslider. My slider is showing 2 items in a slide. In my first item, I have a button will trigger colorbox which is runs fine at first slide (activePage). When the slider changing, my first item which fall on second panel, there is a issue trigger my colorbox. I saw an error: Error: cboxElement missing settings object

Then when slider changing again, if my first item fall back to the first panel (activePage), it working properly.

I wonder why anythingSlider has this issue with colobox only if it not at the first panel (activePage).

Mottie commented 12 years ago

Could you please share some code, demo or even a live site of this issue.

claudchan commented 12 years ago

Hi Mottie, Here is the demo: http://jsfiddle.net/claudchan/hW34t/

Mottie commented 12 years ago

Ahh ok, the problem is that the cbox isn't being initialized on the cloned slide. Move the call to cbox() to inside of the onInitialized callback function and it will start working (demo):

var cbox = function(){
        $('.cbox-content').colorbox({
            iframe: true,
            opacity: 0.75,
            innerWidth: 400,
            innerHeight: 350
        });
    },
    $otherslider = $('#other-slider-items');

$otherslider.anythingSlider({
    hashTags: false,
    resizeContents: false,
    buildStartStop: false,
    buildNavigation: false,
    autoPlay: true,
    autoPlayLocked: true,
    delay: 5000,
    resumeDelay: 5000,
    showMultiple: 2,
    changeBy: 1,
    infiniteSlides: true,
    stopAtEnd: false,
    onInitialized: function(e,slider){
        cbox();
    }
});
claudchan commented 12 years ago

Wow, works like charm! Thanks!