확장easyui-tabs 플러그인 탭 닫기 방법

2329 단어 easyui
    $.extend($.fn.tabs.methods,{
        allTabs:function(jq){
            var tabs = $(jq).tabs('tabs');
            var all = [];
            all = $.map(tabs,function(n,i){
                 return $(n).panel('options')
            });
            return all;
        },
        closeCurrent: function(jq){ //  
            var currentTab = $(jq).tabs('getSelected'),
                currentTabIndex = $(jq).tabs('getTabIndex',currentTab);
             $(jq).tabs('close',currentTabIndex);
        },
        closeAll:function(jq){ // 
            var tabs = $(jq).tabs('allTabs');
            $.each(tabs,function(i,n){
                $(jq).tabs('close', n.title);
            })
        },
        closeOther:function(jq){ // tab 
            var tabs =$(jq).tabs('allTabs');
            var currentTab = $(jq).tabs('getSelected'),
                currentTabIndex = $(jq).tabs('getTabIndex',currentTab);

            $.each(tabs,function(i,n){
                if(currentTabIndex != i) {
                    $(jq).tabs('close', n.title);
                }
            })
        },
        closeLeft:function(jq){ //  tab 
            var tabs = $(jq).tabs('allTabs');
            var currentTab = $(jq).tabs('getSelected'),
                currentTabIndex = $(jq).tabs('getTabIndex',currentTab);
            var i = currentTabIndex-1;

            while(i > -1){
                $(jq).tabs('close', tabs[i].title);
                i--;
            }
        },
        closeRight: function(jq){ ////  tab 
            var tabs = $(jq).tabs('allTabs');
            var currentTab = $(jq).tabs('getSelected'),
                currentTabIndex = $(jq).tabs('getTabIndex',currentTab);
            var i = currentTabIndex+ 1,len = tabs.length;
            while(i < len){
                $(jq).tabs('close', tabs[i].title);
                i++;
            }
        }
    })

좋은 웹페이지 즐겨찾기