為jQuery-easyui的tab組件添加右鍵菜單功能的簡單實例
更新時間:2016年10月10日 08:40:37 投稿:jingxian
下面小編就為大家?guī)硪黄獮閖Query-easyui的tab組件添加右鍵菜單功能的簡單實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
加入了右擊TAB選項卡時顯示關閉的上下文菜單
具體實現(xiàn)代碼:
右鍵菜單 HTML:
<div id="mm" class="easyui-menu" style="width:150px;">
<div id="mm-tabclose">關閉</div>
<div id="mm-tabcloseall">全部關閉</div>
<div id="mm-tabcloseother">除此之外全部關閉</div>
<div class="menu-sep"></div>
<div id="mm-tabcloseright">當前頁右側(cè)全部關閉</div>
<div id="mm-tabcloseleft">當前頁左側(cè)全部關閉</div>
</div>
下面是js代碼:
$(function(){
tabClose();
tabCloseEven();
})
function tabClose()
{
/*雙擊關閉TAB選項卡*/
$(".tabs-inner").dblclick(function(){
var subtitle = $(this).children("span").text();
$('#tabs').tabs('close',subtitle);
})
$(".tabs-inner").bind('contextmenu',function(e){
$('#mm').menu('show', {
left: e.pageX,
top: e.pageY,
});
var subtitle =$(this).children("span").text();
$('#mm').data("currtab",subtitle);
return false;
});
}
//綁定右鍵菜單事件
function tabCloseEven()
{
//關閉當前
$('#mm-tabclose').click(function(){
var currtab_title = $('#mm').data("currtab");
$('#tabs').tabs('close',currtab_title);
})
//全部關閉
$('#mm-tabcloseall').click(function(){
$('.tabs-inner span').each(function(i,n){
var t = $(n).text();
$('#tabs').tabs('close',t);
});
});
//關閉除當前之外的TAB
$('#mm-tabcloseother').click(function(){
var currtab_title = $('#mm').data("currtab");
$('.tabs-inner span').each(function(i,n){
var t = $(n).text();
if(t!=currtab_title)
$('#tabs').tabs('close',t);
});
});
//關閉當前右側(cè)的TAB
$('#mm-tabcloseright').click(function(){
var nextall = $('.tabs-selected').nextAll();
if(nextall.length==0){
//msgShow('系統(tǒng)提示','后邊沒有啦~~','error');
alert('后邊沒有啦~~');
return false;
}
nextall.each(function(i,n){
var t=$('a:eq(0) span',$(n)).text();
$('#tabs').tabs('close',t);
});
return false;
});
//關閉當前左側(cè)的TAB
$('#mm-tabcloseleft').click(function(){
var prevall = $('.tabs-selected').prevAll();
if(prevall.length==0){
alert('到頭了,前邊沒有啦~~');
return false;
}
prevall.each(function(i,n){
var t=$('a:eq(0) span',$(n)).text();
$('#tabs').tabs('close',t);
});
return false;
});
}
以上就是小編為大家?guī)淼臑閖Query-easyui的tab組件添加右鍵菜單功能的簡單實例全部內(nèi)容了,希望大家多多支持腳本之家~
相關文章
jQuery動態(tài)生成不規(guī)則表格(前后端)
這篇文章主要介紹了jQuery動態(tài)生成不規(guī)則表格的實現(xiàn)代碼,非常不錯,具有參考借鑒價值,需要的朋友參考下2017-02-02
Jquery 數(shù)據(jù)選擇插件Pickerbox使用介紹
目前市面上很少見或幾乎沒有這數(shù)據(jù)(對象)選擇插件.比如,點擊input , select 元素時彈出div(窗口),載入數(shù)據(jù)讓用戶選擇數(shù)據(jù),選擇后在填充回對應的元素.2012-08-08
淺析Bootstrip的select控件綁定數(shù)據(jù)的問題
這篇文章主要介紹了淺析Bootstrip的select控件綁定數(shù)據(jù)的問題 的相關資料,小編認為非常具有參考價值,感興趣的朋友一起看下吧2016-05-05
JQuery中使用ajax傳輸超大數(shù)據(jù)的解決方法
這篇文章主要介紹了JQuery中使用ajax傳輸超大數(shù)據(jù)的解決方法,也就是比較多的數(shù)據(jù),超過max_upload_size等設置,本文方法在chrome瀏覽器下測試通過,需要的朋友可以參考下2014-07-07
jQuery實現(xiàn)鏈接的title快速出現(xiàn)的方法
這篇文章主要介紹了jQuery實現(xiàn)鏈接的title快速出現(xiàn)的方法,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2017-02-02

