WordPress.org

Ready to get started?Download WordPress

Forums

Featured Item Slider
JS error when no slider on page (3 posts)

  1. freerange
    Member
    Posted 1 year ago #

    If there is no slider on the page your script throws an error

    startSlideshow: function() {
    jQuery('div.content_slideshow > ul', $slideshow.context).cycle({
    Uncaught TypeError: Object [object Object] has no method 'cycle'

    See http://themedialeak.com/nfl-torrey-smith-no-fan-of-pats/

    http://wordpress.org/extend/plugins/featured-item-slider/

  2. makta112
    Member
    Posted 1 year ago #

    Any way to avoid this?

  3. freerange
    Member
    Posted 1 year ago #

    Replace the slideshow.js file with this one - it adds 2 lines

    if(!document.getElementById("content-slideshow"))
    		return;		//Bail if we don't have a slideshow

    This causes it to bail gracefully if there is no slideshow on the page

    // Tutorial by http://ooyes.net/
    
    $slideshow = {
    	context: false,
    	tabs: false,
    	timeout: 8000,
    	fx: 'fade',
    	slideSpeed: 900,
    	tabSpeed: 900,   
    
        init: function() {
    	if(!document.getElementById("content-slideshow"))
    		return;		//Bail if we don't have a slideshow
            this.context = jQuery('#content-slideshow');
            this.tabs = jQuery('ul.slideshow-nav li', this.context);
            this.tabs.remove();
            this.startSlideshow();
        },
    
        startSlideshow: function() {
    
            jQuery('div.content_slideshow > ul', $slideshow.context).cycle({
                fx: $slideshow.fx,
                pager: jQuery('ul.slideshow-nav', $slideshow.context),
                pagerAnchorBuilder: $slideshow.startTabs,
                before: $slideshow.Tabactive,
    	    timeout: $slideshow.timeout,
                speed: $slideshow.slideSpeed,
                fastOnEvent: $slideshow.tabSpeed,
                pauseOnPagerHover: true,
                pause: true
            });
        },
    
        startTabs: function(i, slide) {
            return $slideshow.tabs.eq(i);
        },
    
        Tabactive: function(currentSlide, nextSlide) {
            var activeTab = jQuery('a[href="#' + nextSlide.id + '"]', $slideshow.context);
            if(activeTab.length) {
                $slideshow.tabs.removeClass('on');
                activeTab.parent().addClass('on');
            }
        }
    };
    
    jQuery(document).ready(function($) {
        $slideshow.init();
    });

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.