easyui扩展tabs

(function () {
   $.extend($.fn.tabs.methods, {
        getTabById: function(jq,id) {
            var tabs = $.data(jq[0], 'tabs').tabs;
            for(var i=0; i<tabs.length; i++){
                var tab = tabs[i];
                if (tab.panel('options').id == id){
                    return tab;
                }
            }
            return null;
        },
        selectById:function(jq,id) {
            return jq.each(function() {
                var state = $.data(this, 'tabs');
                var opts = state.options;
                var tabs = state.tabs;
                var selectHis = state.selectHis;
                if (tabs.length == 0) {return;}
                var panel = $(this).tabs('getTabById',id); // get the panel to be activated 
                if (!panel){return}
                var selected = $(this).tabs('getSelected');
                if (selected){
                    if (panel[0] == selected[0]){return}
                    $(this).tabs('unselect',$(this).tabs('getTabIndex',selected));
                    if (!selected.panel('options').closed){return}
                }
                panel.panel('open');
                var title = panel.panel('options').title;        // the panel title 
                selectHis.push(title);        // push select history 
                var tab = panel.panel('options').tab;        // get the tab object 
                tab.addClass('tabs-selected');
                // scroll the tab to center position if required. 
                var wrap = $(this).find('>div.tabs-header>div.tabs-wrap');
                var left = tab.position().left;
                var right = left + tab.outerWidth();
                if (left < 0 || right > wrap.width()){
                    var deltaX = left - (wrap.width()-tab.width()) / 2;
                    $(this).tabs('scrollBy', deltaX);
                } else {
                    $(this).tabs('scrollBy', 0);
                }
                $(this).tabs('resize');
                opts.onSelect.call(this, title, $(this).tabs('getTabIndex',panel));
            });
        },
        existsById:function(jq,id){
            return $(jq[0]).tabs('getTabById',id) != null;
        }
    });
})(jQuery);

判断

var isOpen = $('#tabs').tabs('existsById', node.id);
		if (isOpen) {
			$('#tabs').tabs('selectById', node.id);
			var tab = $('#tabs').tabs('getTabById', node.id);
			tab.panel('refresh');
			return;
		}

 

转载于:https://my.oschina.net/xinyuanKong/blog/694981

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值