jQuery Cycle Plugin [cycle] terminating; too few slides: 1

Jae Kun Choi picture Jae Kun Choi · Nov 2, 2011 · Viewed 10.3k times · Source

I'm getting below error:

[cycle] terminating; too few slides: 1

Below is the code for jQuery Cycle. I'm not sure why this is coming out in Chrome

var inners = $('ul#output li').cycle().cycle('stop');

        var slideshow = $('ul#output').cycle({
            fx: 'scrollHorz',
            speed: 300,
            timeout: 0,
            startingSlide: 0, 
            before: function() {

                // stop all inner slideshows
                inners.cycle('stop');

                // start the new slide's slideshow
                $(this).cycle({
                    fx: 'fade',
                    timeout: 1000,
                    autostop: true,
                    end: function() {
                        // when inner slideshow ends, advance the outer slideshow
                        slideshow.cycle('next');
                    }
                });
            }
        });

        $.featureList(
                $("#tabs li a"),
                $("#output li"), {
                    start_item  :   0
                }
            ); 

What could be wrong?

Answer

Mudassar Ali Sahil picture Mudassar Ali Sahil · Jun 3, 2014

actually this error comes when your sliding elements Less than 2. if you want to run cycle plugin in single element also then go to

jquery.cycle.all.js

and find

if (els.length < 2) {
            log('terminating; too few slides: ' + els.length);
            return;
        }

and change the condition limit to 1 like

if (els.length < 1) {
            log('terminating; too few slides: ' + els.length);
            return;
        }

if you don't want run single element then you should put condition on your language side that render element if elements count > 2

Cheers!

Mudassar Ali