2011-11-02 95 views
3

我收到以下錯誤:jQuery Cycle Plugin [循環]終止;幻燈片太少:1

[cycle] terminate;太少的幻燈片:1

以下是jQuery Cycle的代碼。我不知道爲什麼這會出現在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 
       } 
      ); 

什麼可能是錯的?

回答

1

這是值得您的第一行:

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

您正在試圖創建一個.cicle()裏面.cicle()。如果您嘗試:

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

它不會返回任何錯誤。

3

其實這個錯誤出現,當你滑動元件小於2 ,如果你想運行在單個元素週期插件也再 去

jquery.cycle.all.js

,並找到

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

和變化條件限制爲1像

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

如果你不想運行單個元素,那麼你應該把語言方面的條件 渲染元素,如果元素數> 2

乾杯!

Mudassar Ali

相關問題