javascript – 如何扩展jQuery手风琴插件

前端之家收集整理的这篇文章主要介绍了javascript – 如何扩展jQuery手风琴插件前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何扩展jQuery插件

目前我正在使用multiopen accordion插件.

我需要添加功能,一旦展开/崩溃完成,我需要回调一个函数,就像jquery ui手风琴插件中的更改事件一样.

如何在此插件添加功能.

解决方法

$.extend($.ui.multiAccordion,{    
    // private helper method that used to show tabs
    _showTab: function($this) {
        var $span = $this.children('span.ui-icon');
        var $div = $this.next();
        var options = this.options;
        $this.removeClass('ui-state-default ui-corner-all').addClass('ui-state-active ui-corner-top');
        $span.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
        // MODIIFICATION
        bindThis = this;
        var ui = {
            tab: $this,content: $this.next('div')
        }
        $div.slideDown('fast',function(){
            $div.addClass(options._classes.divActive);
            // MODIFICATION
            bindThis._trigger('tabShownComplete');
        });
        this._trigger('tabShown',null,ui);
    },// private helper method that used to show tabs 
    _hideTab: function($this) {
        var $span = $this.children('span.ui-icon');
        var $div = $this.next();
        var options = this.options;
        $this.removeClass('ui-state-active ui-corner-top').addClass('ui-state-default ui-corner-all');
        $span.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
        // MODIIFICATION
        bindThis = this;
        var ui = {
            tab: $this,content: $this.next('div')
        }
        $div.slideUp('fast',function(){
            $div.removeClass(options._classes.divActive);
            // MODIFICATION
            bindThis._trigger('tabHiddenComplete',ui);
        });
        this._trigger('tabHidden',ui);
    }
});

> https://gist.github.com/4342758

原文链接:https://www.f2er.com/jquery/153607.html

猜你在找的jQuery相关文章