<div id="tt" style="width: 500px; height: 364px;"></div>
$('#tt').tabs({
closable : true,
tabPosition : 'left',
headerWidth : 100
});// 拿到tabs下面的tab 生成一个数组
var tabArray = $('#tt').tabs("tabs");
var cnt = 0;
if (tabArray.length != 0) {
/**
* tabArray =0 时代表暂无选项卡,当前创建的为第一个
* 并且 循环遍历 已有选项卡 和当前将要创建的选项卡比较 避免打开重复的 选项卡
*/
for ( var i = 0; i < tabArray.length; i++) {
if (rowData.userId == tabArray[i][0].id) {//取到tab中的id
cnt++;
break;
}
}
if (cnt == 0) {
addTab(rowData.userId, rowData.userName);
}
} else {
addTab(rowData.userId, rowData.userName);
}
function addTab(userId, userName) {
$('#tt').tabs('add', {
id : userId,
title : userName,
selected : false,
closable : true,
content : function() {
//此处为 聊天内容
return userId + " " + userName;
}
});
}
easyui 添加不重复的tab选项卡
最新推荐文章于 2021-06-04 17:12:44 发布