EasyUI Forum
September 13, 2025, 08:37:57 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Choose tab index while adding new tab  (Read 11245 times)
leela
Newbie
*
Posts: 29


View Profile Email
« on: November 12, 2014, 08:18:17 AM »

Hi,

 Is there a way I can define the index of the tab, when adding it, so that I can control the position/sequence of the newly added tab

 Example: Lets I have 2 tabs added already tab X and tab Y.

 I need to add a new tab Z in between the 2 existing tabs X and Y

 Right now it always goes after tab Y

 Please advise.


Thanks,
Leela.
Logged
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« Reply #1 on: November 12, 2014, 08:30:12 PM »

did you already try onAdd event? with that, i think you can get the tab index.
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #2 on: November 12, 2014, 08:44:31 PM »

i can't figure out how to do that...
and i find there is no Drag and Drop feature on tabs , too bad
 
maybe stworthy could solve your problem..

this is my best..just a little bit weird..

take a look here...
http://jsfiddle.net/aswzen/jfqL65o6/

« Last Edit: November 12, 2014, 08:46:22 PM by aswzen » Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
Opan Mustopah
Full Member
***
Posts: 164


Indonesia


View Profile Email
« Reply #3 on: November 12, 2014, 10:33:04 PM »

yes, actually i wait for that feature too sir. i hope it included in next release.
Logged

-- Bajak Otak --
*** Sorry for my bad english :3 ***
--JeasyUI version 1.4--
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #4 on: November 13, 2014, 08:19:47 AM »

Please extend the 'move' method to achieve this functionality.
Code:
$.extend($.fn.tabs.methods, {
move: function(jq, param){
return jq.each(function(){
moveTab(this, param);
function moveTab(target, param){
var state = $.data(target, 'tabs');
var opts = state.options;
var tabs = state.tabs;

if (param.index < 0){param.index = 0}
if (param.index > tabs.length){param.index = tabs.length}

var ul = $(target).children('div.tabs-header').find('ul.tabs');
var li = $(param.tab.panel('options').tab);
if (param.index >= tabs.length){
var tabIndex = $(target).tabs('getTabIndex', param.tab);
tabs.splice(tabIndex, 1);
tabs.push(param.tab);
li.appendTo(ul);
} else {
var pp = [];
$.map(tabs, function(tab, index){
if (index == param.index){
pp.push(param.tab);
}
if (tab[0] != param.tab[0]){
pp.push(tab);
}
});
state.tabs = pp;
li.insertBefore(ul.children('li:eq('+param.index+')'));
}
}
});
}
})

Usage example:
Code:
var t = $('#tt');
var tab = t.tabs('getTab', 2);  // get the tab panel
t.tabs('move', {
  tab: tab,
  index: 1  // move to index 1
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!