御宅男

御宅男

600飞吻 2016-10-14 加入 来自苏州

(这个人懒得留下签名)

御宅男 最近的提问

御宅男 最近的回答

  • 16小时前导航栏怎么做,导航栏不刷新,界面刷新中回答:

    https://gitee.com/ken678/YZNCMS/tree/tp5.1
    thinkphp5.1的
  • 2天前简单的下拉框问题中回答:

    $(this).find("option:selected").attr("data-ifoption"); 这样不行
  • 2天前静态表格前端如何禁止排序?中回答:

    sort: true不要设置不就行了
  • 2天前简单的下拉框问题中回答:

    @ 获取data-ifoption的值
  • 2018-5-18 18:10:7layui引入到thinkphp框架路径中回答:

    TP5.1可以看下我的https://gitee.com/ken678/YZNCMS/tree/tp5.1
  • 2018-5-10 23:8:1后台如何接收layui表单的复选框(checkbox)的值中回答:

    name="like[]" value="write"
  • 2018-5-10 23:3:36后台如何接收layui表单的复选框(checkbox)的值中回答:

    很简单 前台这样判断开关
    form.on('switch', function(data) {
    $(data.elem).attr('type', 'hidden').val(this.checked ? 1 : 0);
    });
    或者后台判断这个字段没有就为
  • 2018-5-10 22:55:41切换tab页面展示不全中回答:

    https://gitee.com/ken678/YZNCMS/tree/tp5.1 我页面和你一模一样 你可以看看
  • 2018-5-9 7:55:15layui搜索后出现的不适应中回答:

    某一列不要设置宽度
  • 2018-4-26 16:56:37click 默认点击事件失效中回答:

    @一条大菜狗 弄了半天 把click事件互换位置就好了 [亲亲]
  • 2018-4-26 16:44:30click 默认点击事件失效中回答:

    @御宅男 @黄色的剑 以上代码实现的效果
  • 2018-4-26 16:37:4click 默认点击事件失效中回答:

    //顶部点击一个tab页
    $('#B_history').on('click focus', 'li', function(e) {
    e.preventDefault();
    e.stopPropagation();
    var data_id = $(this).data('id');
    if (data_id) {
    //选择顶部菜单
    var curid = data_id;
    if (curid == "default") curid = "changyong";
    var topmenu = getTopMenuByID(curid);
    var objtopmenu = $('#J_B_main_block').find("a[data-id=" + topmenu.id + "]");
    if (objtopmenu.parent().attr("class") != "layui-this") {
    //选中当前顶部菜单
    objtopmenu.parent().addClass('layui-this').siblings().removeClass('layui-this');
    //触发事件
    objtopmenu.click();
    }
    //选择左边菜单
    $("#B_menubar").find(".layui-this").removeClass('layui-this');
    $("#B_menubar").find("a[data-id=" + data_id + "]").parent().addClass('layui-this');
    }

    $(this).addClass('layui-this').siblings('li').removeClass('layui-this');
    try {
    var menuid = parseInt(data_id);
    if (menuid) {
    setCookie("menuid", menuid);
    }
    } catch (err) {}
    $('#iframe_' + data_id).show().siblings('iframe').hide(); //隐藏其它iframe
    });

    //顶部关闭一个tab页
    $('#B_history').on('click', '.layui-tab-close', function(e) {
    e.stopPropagation();
    e.preventDefault();
    var li = $(this).parent(),
    prev_li = li.prev('li'),
    data_id = li.attr('data-id');
    li.hide(60, function() {
    $(this).remove(); //移除选项卡
    $('#iframe_' + data_id).remove(); //移除iframe页面
    var current_li = $('#B_history li.layui-this');
    //找到关闭后当前应该显示的选项卡
    current_li = current_li.length ? current_li : prev_li;
    current_li.addClass('layui-this');
    cur_data_id = current_li.attr('data-id');
    $('#iframe_' + cur_data_id).show();
    });
    });

    //显示顶部导航时作位置判断,点击左边菜单、上一tab、下一tab时公用
    function showTab(li) {
    if (li.length) {
    /*var ul = $('#B_history'),
    li_offset = li.offset(),
    li_width = li.outerWidth(true),
    next_left = $('#J_next').offset().left - 9, //右边按钮的界限位置
    prev_right = $('#J_prev').offset().left + $('#J_prev').outerWidth(true); //左边按钮的界限位置
    if (li_offset.left + li_width > next_left) { //如果将要移动的元素在不可见的右边,则需要移动
    var distance = li_offset.left + li_width - next_left; //计算当前父元素的右边距离,算出右移多少像素
    ul.animate({
    left: '-=' + distance
    }, 200, 'swing');
    } else if (li_offset.left < prev_right) { //如果将要移动的元素在不可见的左边,则需要移动
    var distance = prev_right - li_offset.left; //计算当前父元素的左边距离,算出左移多少像素
    ul.animate({
    left: '+=' + distance
    }, 200, 'swing');
    }*/
    li.trigger('click');
    }
    }

    //通过菜单id查找菜单配置对象
    function getMenuByID(mid, menugroup) {
    var ret = {};
    mid = parseInt(mid);
    if (!menugroup) menugroup = SUBMENU_CONFIG;
    if (isNaN(mid)) {
    ret = menugroup['changyong'];
    } else {
    $.each(menugroup, function(i, o) {
    if (o.id && parseInt(o.id) == mid) {
    ret = o;
    return false
    } else if (o.items) {
    var tmp = getMenuByID(mid, o.items);
    if (tmp.id && parseInt(tmp.id) == mid) {
    ret = tmp;
    return false
    }
    }
    });
    }
    return ret;
    }

    function getTopMenuByID(mid) {
    var ret = {};
    var menu = getMenuByID(mid);
    if (menu) {
    if (menu.parent) {
    var tmp = getTopMenuByID(menu.parent);
    if (tmp && tmp.id) {
    ret = tmp;
    }
    } else {
    ret = menu;
    }
    }
    return ret;
    }


    //手机设备的简单适配
    var treeMobile = $('.site-tree-mobile'),
    shadeMobile = $('.site-mobile-shade')
    treeMobile.on('click', function() {
    $('body').addClass('site-mobile');
    });
    shadeMobile.on('click', function() {
    $('body').removeClass('site-mobile');
    });

    //用于维持在线
    function online() {}


    })
    </script>

    </body>

    </html>
  • 2018-4-26 16:36:34click 默认点击事件失效中回答:

        <script src="http://www.yzncms.com/static/layui/layui.js"></script>
    <script type="text/javascript">
    layui.use(['element', 'layer', 'jquery'], function() {
    var $ = layui.jquery;
    var element = layui.element;
    var layer = layui.layer;

    var SUBMENU_CONFIG = {"1admin":{"menuid":1,"id":"1admin","title":"\u6211\u7684\u9762\u677f","icon":"","parent":"","url":"\/admin\/public_main\/index\/menuid\/1.html","items":{"10admin":{"menuid":10,"id":"10admin","title":"\u4e2a\u4eba\u4fe1\u606f","icon":"","parent":1,"url":"\/admin\/manage\/index\/menuid\/10.html","items":{"11admin":{"menuid":11,"id":"11admin","title":"\u4fee\u6539\u4e2a\u4eba\u4fe1\u606f","icon":"","parent":10,"url":"\/admin\/manage\/myinfo\/menuid\/11.html"},"12admin":{"menuid":12,"id":"12admin","title":"\u4fee\u6539\u5bc6\u7801","icon":"","parent":10,"url":"\/admin\/manage\/chanpass\/menuid\/12.html"}}}}},"2admin":{"menuid":2,"id":"2admin","title":"\u8bbe\u7f6e","icon":"","parent":"","url":"\/admin\/setting\/index\/menuid\/2.html"},"3admin":{"menuid":3,"id":"3admin","title":"\u6a21\u5757","icon":"","parent":"","url":"\/admin\/module\/index\/menuid\/3.html"},"4admin":{"menuid":4,"id":"4admin","title":"\u6269\u5c55","icon":"","parent":"","url":"\/admin\/addons\/index\/menuid\/4.html"}};

    //iframe 加载事件
    /*var iframe_default = document.getElementById('iframe_default');
    var def_iframe_height = 0;
    $(iframe_default.contentWindow.document).ready(function() {
    /*setTimeout(function() {
    $('#loading').hide();
    }, 500);
    $(iframe_default).show();
    });*/

    //顶部菜单展示
    $(function() {
    var html = [];
    //iframe_height();
    //console.log(SUBMENU_CONFIG);
    $.each(SUBMENU_CONFIG, function(i, o) {
    html.push('<li class="layui-nav-item"><a href="javascript:;" title="' + o.title + '" data-id="' + o.id + '">' + o.title + '</a></li>');
    });
    $('#J_B_main_block').html(html.join(''));
    element.render(); //重新渲染
    //后台位在第一个导航
    $('#J_B_main_block li:first > a').trigger("click");
    //维持在线
    setInterval(function() {
    online();
    }, 60000);
    });

    //顶部导航点击
    $('#J_B_main_block').on('click', 'a', function(e) {

    //取消事件的默认动作
    e.preventDefault();
    //终止事件 不再派发事件
    e.stopPropagation();
    $(this).parent().addClass('current').siblings().removeClass('current');
    var data_id = $(this).attr('data-id'),
    data_list = SUBMENU_CONFIG[data_id],
    html = [],
    child_html = [],
    child_index = 0,
    B_menubar = $('#B_menubar');

    if (B_menubar.attr('data-id') == data_id) {
    return false;
    };
    //显示左侧菜单
    //console.log(data_list['items']);
    show_left_menu(data_list['items']);
    B_menubar.html(html.join('')).attr('data-id', data_id);
    element.render(); //重新渲染
    //左侧导航复位
    //$("#B_menunav").css({ "margin-top": "0px" });
    //检查是否应该出现上一页、下一页
    //checkMenuNext();
    //
    //显示左侧菜单
    function show_left_menu(data) {
    for (var attr in data) {
    if (data[attr] && typeof(data[attr]) === 'object') {
    //循环子对象
    if (!data[attr].url && attr === 'items') {
    //子菜单添加识别属性
    $.each(data[attr], function(i, o) {
    child_index++;
    o.isChild = true;
    o.child_index = child_index;
    });
    }
    show_left_menu(data[attr]); //继续执行循环(筛选子菜单)
    } else {
    if (attr === 'title') {
    data.url = data.url ? data.url : '#';
    if (!(data['isChild'])) {
    //一级菜单
    html.push('<li class="layui-nav-item"><a href="' + data.url + '" data-id="' + data.id + '"><b>' + data.title + '</b></a>');
    } else {
    //二级菜单
    child_html.push('<dd><a href="' + data.url + '" data-id="' + data.id + '">' + data.title + '</a></dd>');
    //二级菜单全部push完毕
    if (data.child_index == child_index) {
    html.push('<dl class="layui-nav-child">' + child_html.join('') + '</dl></li>');
    child_html = [];
    }
    }
    }
    }
    }
    };
    });

    //左边菜单点击
    $('#B_menubar').on('click', 'a', function(e) {
    e.preventDefault();
    e.stopPropagation();
    //iframe_height();
    var $this = $(this),
    _dt = $this.parent(),
    _dl = $this.next('dl');
    //$("#B_menubar li").removeClass('current');
    //当前菜单状态
    //_dt.addClass('current').siblings('dt.current').removeClass('current');
    //子菜单显示&隐藏
    if (_dl.length) {
    //_dt.toggleClass('current');
    //_dl.toggle();
    //检查上下分页
    //checkMenuNext();
    return false;
    };

    //$('#loading').show().focus(); //显示loading
    //$('#B_history li').removeClass('current');
    var data_id = $(this).attr('data-id'),
    li = $('#B_history li[data-id=' + data_id + ']');
    var href = this.href;

    iframeJudge({
    elem: $this,
    href: href,
    id: data_id
    });

    });

    //判断显示或创建iframe
    function iframeJudge(options) {
    var elem = options.elem,
    href = options.href,
    id = options.id,
    li = $('#B_history li[data-id=' + id + ']');

    //如果iframe标签是已经存在的,则显示并让选项卡高亮,并不显示loading
    if (li.length > 0) {
    var iframe = $('#iframe_' + id);
    setTimeout(function() {
    $('#loading').hide();
    }, 500);
    li.addClass('current');
    if (iframe[0].contentWindow && iframe[0].contentWindow.location.href !== href) {
    iframe[0].contentWindow.location.href = href;
    }
    $('#B_frame iframe').hide();
    $('#iframe_' + id).show();
    showTab(li); //计算此tab的位置,如果不在屏幕内,则移动导航位置
    } else {
    //创建一个并加以标识
    var iframeAttr = {
    src: href,
    id: 'iframe_' + id,
    frameborder: '0',
    scrolling: 'auto',
    height: '100%',
    width: '100%'
    };
    var iframe = $('<iframe/>').prop(iframeAttr).appendTo('#B_frame .layui-tab-content .iframe_box');

    $(iframe[0].contentWindow.document).ready(function() {
    $('#B_frame iframe').hide();
    setTimeout(function() {
    $('#loading').hide();
    }, 500);
    var li = $('<li>' + elem.html() + '<i class="layui-icon layui-unselect layui-tab-close">ဆ</i></li>').attr('data-id', id);
    li.appendTo('#B_history');
    showTab(li); //计算此tab的位置,如果不在屏幕内,则移动导航位置
    //$(this).show().unbind('load');
    });
    }
    }
  • 2018-4-26 16:35:44click 默认点击事件失效中回答:

    @一条大菜狗
    <!DOCTYPE html>
    <html>

    <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="http://www.yzncms.com/static/layui/css/layui.css">

    </head>

    <body>
    <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
    <a href="#" class="logo">YZNCMS后台</a>
    <!--<ul class="layui-nav mobileTopLevelMenus">
    <li class="layui-nav-item">
    <a href="javascript:;">导航分类<span class="layui-nav-more"></span></a>
    <dl class="layui-nav-child">
    <dd><a href="javascript:;">内容管理</a></dd>
    <dd><a href="javascript:;">用户中心</a></dd>
    <dd><a href="javascript:;">系统设置</a></dd>
    <dd><a href="javascript:;">使用文档</a></dd>
    </dl>
    </li>
    </ul>-->
    <ul class="layui-nav layui-layout-left topLevelMenus" id="J_B_main_block">
    <!--AJAX数据-->
    </ul>
    <ul class="layui-nav layui-layout-right">
    <li class="layui-nav-item"><a href="javascript:;"><img src="" class="layui-nav-img">贤心</a>
    <dl class="layui-nav-child">
    <dd><a href="">基本资料</a></dd>
    <dd><a href="">安全设置</a></dd>
    </dl>
    </li>
    </ul>
    </div>
    <div class="layui-side layui-bg-black">
    <div class="navBar layui-side-scroll" id="navBar">
    <ul class="layui-nav layui-nav-tree" id="B_menubar">
    <!--AJAX数据-->
    </ul>
    </div>
    </div>
    <div class="site-tree-mobile layui-hide">
    <i class="layui-icon"></i>
    </div>
    <div class="site-mobile-shade"></div>
    <div class="layui-body" id="B_frame">
    <ul class="layui-tab-title top_tab" id="B_history">
    <li class="layui-this" data-id="default"><i class="layui-icon"></i> 后台首页
    </li>
    </ul>
    <div class="layui-tab-content clildFrame">
    <div class="iframe_box">
    <iframe id="iframe_default" src="/admin/main/index.html" style="height: 100%; width: 100%;display:none;" data-id="default" frameborder="0" scrolling="auto"></iframe>
    </div>
    </div>
    </div>
    <div class="layui-footer">
    © YZNCMS V1.0.0
    </div>
    </div>
  • 2018-4-26 16:35:12click 默认点击事件失效中回答:

    @一条大菜狗 大神 我把代码 都拷过来了 你看下 就是js和css你换成本地的