Add the right-click menu function for the tab component of Jquery-easyui

Source: Internet
Author: User

Display closed context menu when right-click tab tab is added

Specific implementation code:

Right-click menu HTML:

<div id= "MM" class= "Easyui-menu" style= "width:150px;" >
<div id= "Mm-tabclose" > Close </div>
<div id= "Mm-tabcloseall" > Close all </div>
<div id= "Mm-tabcloseother" > all except Close </div>
<div class= "Menu-sep" ></div>
<div id= "mm-tabcloseright" > Current page right all close </div>
<div id= "Mm-tabcloseleft" > current page left all close </div>
</div>

Here is the JS code:

$ (function () {
Tabclose ();
Tabcloseeven ();
})

function Tabclose ()
{
/* Double-click to close Tab 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;
});
}


Binding Right-click menu events
function Tabcloseeven () {
Close the current
$ (' #mm-tabclose '). Click (function () {
var currtab_title = $ (' #mm '). Data ("Currtab");
$ (' #tabs '). Tabs (' Close ', currtab_title);
});
  

Close all
$ (' #mm-tabcloseall '). Click (function () {
$ ('. Tabs-inner span '). each (function (i,n) {
var t = $ (n). text ();
$ (' #tabs '). Tabs (' Close ', t);
});
});
  

Close tab except for current
$ (' #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);
});
});

Close the current tab on the right
$ (' #mm-tabcloseright '). Click (function () {
var Nextall = $ ('. tabs-selected '). Nextall ();
if (nextall.length==0) {
Msgshow (' System hint ', ' there is no ~ ~ ', ' error ');
Alert (' No Back ~ ~ ');
return false;
}
    

Nextall.each (function (i,n) {
var t=$ (' a:eq (0) span ', $ (n)). text ();
$ (' #tabs '). Tabs (' Close ', t);
});
return false;
});

Close the tab at the left of the current
$ (' #mm-tabcloseleft '). Click (function () {
var Prevall = $ ('. tabs-selected '). Prevall ();
if (prevall.length==0) {
Alert (' At the end, not in front ~ ~ ');
return false;
}
Prevall.each (function (i,n) {
var t=$ (' a:eq (0) span ', $ (n)). text ();
$ (' #tabs '). Tabs (' Close ', t);
});
return false;
});
}

Add the right-click menu function for the tab component of Jquery-easyui

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.