无法读取未定义控制台的属性'wrapup'

时间:2016-05-07 07:00:40

标签: javascript jquery slider

嘿所有我在我的网站中使用flexslider滑块滑块在http://www.reurl.in/31830875a的服务器上正常运行但是当在本地服务器上检查或在其他地方生活时我在控制台中收到此错误“无法读取属性未定义的'wrapup'和滑块无法正常工作

这是函数

function FlexsliderManualDirectionControls( element, options ) {
    this.element = element;
    this.options = $.extend( {}, defaults, options) ;
    this._flexslider = $(element).data('flexslider');
    this._originalFlexsliderWrapupFunction = this._flexslider.wrapup;
    this._defaults = defaults;
    this._name = flexsliderManualDirectionControls;
    this.init();
}

这只是整页代码中的一个功能。 控制台在this._originalFlexsliderWrapupFunction = this._flexslider.wrapup;

处说错误

如果您发现有用的内容,请回复。

如果你需要完整的代码

/*jshint bitwise:true, curly:true, eqeqeq:true, forin:true, immed:false, latedef:true, newcap:true, noarg:true, noempty:true, nonew:true, undef:true, strict:false, trailing:true, browser:true, jquery:true */
/*!
* jQuery flexslider extension
* Original author: @markirby
* Licensed under the MIT license
*/

(function ( $, window, document, undefined ) {
    var flexsliderManualDirectionControls = 'flexsliderManualDirectionControls',
    defaults = {
        previousElementSelector: ".previous",
        nextElementSelector: ".next",
        disabledStateClassName: "disable"
    };

    function FlexsliderManualDirectionControls( element, options ) {
        this.element = element;
        this.options = $.extend( {}, defaults, options);
        this._flexslider = $(element).data('flexslider');
        this._originalFlexsliderWrapupFunction = this._flexslider.wrapup;
        this._defaults = defaults;
        this._name = flexsliderManualDirectionControls;
        this.init();
    }

    FlexsliderManualDirectionControls.prototype.init = function () {
        this.addEventListeners();
        var self = this;
        this._flexslider.wrapup = function(direction) {
            self.onAnimationEnd.call(self, direction);
        };
    };

    FlexsliderManualDirectionControls.prototype.addEventListeners = function() {
        $(this.element).find(this.options.previousElementSelector).bind('touchstart.flexsliderPromo click.flexsliderPromo', {self:this}, function(event) {
            event.stopPropagation();
            event.preventDefault();  
            if (!event.handled) {
                event.data.self.goToTargetInDirection('prev');
                event.handled = true;
            }

        });
        $(this.element).find(this.options.nextElementSelector).bind('click.flexsliderPromo', {self:this}, function(event) {
            event.stopPropagation();
            event.preventDefault();
            if (!event.handled) {
                event.data.self.goToTargetInDirection('next');
                event.handled = true;
            }
        });
    };

    FlexsliderManualDirectionControls.prototype.goToTargetInDirection = function(direction) {
        var target = this._flexslider.getTarget(direction);
        if (this._flexslider.canAdvance(target)) {
            this._flexslider.flexAnimate(target);
        } 
        return false;
    };

    FlexsliderManualDirectionControls.prototype.addOrRemoveDisabledStateForDirection = function(direction, $navElement) {
        var target = this._flexslider.getTarget(direction);
        if (!this._flexslider.canAdvance(target)) {
            $navElement.addClass(this.options.disabledStateClassName);
        } else {
            $navElement.removeClass(this.options.disabledStateClassName);
        }
    };

    FlexsliderManualDirectionControls.prototype.onAnimationEnd = function(direction) {
        var $nextElement = $(this.element).find(this.options.nextElementSelector),
        $previousElement =    $(this.element).find(this.options.previousElementSelector);
        this.addOrRemoveDisabledStateForDirection('next', $nextElement);
        this.addOrRemoveDisabledStateForDirection('prev', $previousElement);
        this._originalFlexsliderWrapupFunction(direction);
    };

    $.fn[flexsliderManualDirectionControls] = function ( options ) {
        return this.each(function () {
            if (!$.data(this, 'plugin_' + flexsliderManualDirectionControls)) {
                $.data(this, 'plugin_' + flexsliderManualDirectionControls,
                new FlexsliderManualDirectionControls( this, options ));
            }
        });
    };  
})( jQuery, window, document );

0 个答案:

没有答案