zoukankan      html  css  js  c++  java
  • EasyUI Tabs绑定右键

    JS:

                /*为选项卡绑定右键*/
                    $("#tabs").tabs({
                        onContextMenu function(e) {
                            /* 选中当前触发事件的选项卡 */
                            var subtitle $(this).text();
                            $('#tabs').tabs('select', subtitle);
                            //显示快捷菜单
                            e.preventDefault();
                            //阻止冒泡
                            $('#menu').menu('show', {
                                left e.pageX,
                                top e.pageY
                            });
                            return false;
                        }
                    })

                //刷新
                $("#m-refresh").click(function () {
                    var currTab = $('#tabs').tabs('getSelected');    //获取选中的标签项
                    var url = $(currTab.panel('options').content).attr('src');    //获取该选项卡中内容标签(iframe)的 src 属性                 
                    if (url == null) {
                        /* 重新设置该标签 */
                        $('#tabs').tabs('update', {
                            tab: currTab,
                            options: {
                                content: '<iframe frameborder="0"  src="Tabs/Monitoring/MonitoringOfMapType.aspx" style="height: 100%;  100%;" ></iframe>'//如果用herf,容易导致样式与主页面重载,导致页面奔溃.
                            }
                        })
                    }
                    else {
                        /* 重新设置该标签 */
                        $('#tabs').tabs('update', {
                            tab: currTab,
                            options: {
                                content: '<iframe frameborder="0"  src="' + url + '"  style="height: 100%;  100%;" ></iframe>'//如果用herf,容易导致样式与主页面重载,导致页面奔溃.
                            }
                        })
                    }
                });
                //关闭所有
                $("#m-closeall").click(function () {
                    $(".tabs li").each(function (i, n) {
                        var title = $(n).text();
                        if (title != '主页') {//非主页全部关闭
                            $('#tabs').tabs('close', title);
                        }
                    });
                });
                //除当前之外关闭所有
                $("#m-closeother").click(function () {
                    var currTab = $('#tabs').tabs('getSelected');
                    currTitle = currTab.panel('options').title;
                    $(".tabs li").each(function (i, n) {
                        var title = $(n).text();
                        if (currTitle != title && title != '主页') {//除本页和主页以外全部关闭
                            $('#tabs').tabs('close', title);
                        }
                    });
                });
                //关闭当前
                $("#m-close").click(function () {
                    var currTab = $('#tabs').tabs('getSelected');
                    currTitle = currTab.panel('options').title;
                    $('#tabs').tabs('close', currTitle);
                });

    html:

    <%--右键菜单--%>
        <div id="menu" class="easyui-menu" style="width: 150px;">
            <div id="m-refresh" data-options="iconCls:'icon-reload'">
                刷新</div>
            <div class="menu-sep" data-options="iconCls:''">
            </div>
            <div id="m-closeall" data-options="iconCls:''">
                全部关闭</div>
            <div id="m-closeother" data-options="iconCls:''">
                关闭其他</div>
            <div class="menu-sep">
            </div>
            <div id="m-close" data-options="iconCls:'icon-no'">
                关闭</div>
        </div>





  • 相关阅读:
    Crontab中的除号(slash)到底怎么用?
    Crontab设置shell脚本开始执行时间以及结束时间
    CISCO 3750交换机堆叠
    Linux中Too many open files 问题分析和解决
    java 包装类的应用
    Java final修饰符
    Java 多态
    Java 子类初始化过程
    Java 深入变量和封装思想小结
    JaVA web服务器配置
  • 原文地址:https://www.cnblogs.com/nangong/p/4676079.html
Copyright © 2011-2022 走看看