当前位置: 移动技术网 > IT编程>开发语言>.net > MVC+EasyUI+三层新闻网站建立 tabs标签制作方法(六)

MVC+EasyUI+三层新闻网站建立 tabs标签制作方法(六)

2017年12月08日  | 移动技术网IT编程  | 我要评论

孟少农,王只准宠我,sadrun

mvc新闻网站建立,完成tabs标签的制作。

首先对 center 进行一个简单的布局

 <!--------------中间布局开始---------------->
  <div data-options="region:'center',title:'center'" >
    <div class="easyui-tabs" style="width:700px;height:250px" fit="true" id="tt">
      <div title="欢迎使用">
        <h1 style="font-size: 24px;">欢迎!</h1>
        <h1 style="font-size: 24px; color:red;"> welcome !</h1>
      </div>


    </div>

  </div>
  <!--------------中间布局结束--------------->

然后就是在js里面完成tabs的点击事件实现了

其实center就是在div里面嵌入了一个iframe,所以最后返回的就是一个iframe

 <script type="text/javascript">
    $(function () {
      //tabs的点击事件
      bindtabsevent();
    });
    function bindtabsevent() {
      $(".detail").click(function () {
        //拿到点击标题
        var title = $(this).text();
        //拿到点击的url
        var url = $(this).attr("url");
        //判断标签是否存在
        var isext = $("#tt").tabs("exists", title);
        //如果存在则选中
        if (isext) {
          $("#tt").tabs("select", title); //选中
          return;
        }
        //不存在就添加标签
        $("#tt").tabs("add", {
          title: title,
          content: createtabcontent(url),
          closable:true
        });
      });
    }
    function createtabcontent(url) {
      return '<iframe src="' + url + '" scrolling="no" frameborder="0" width="100%" height="100%"></iframe>';
    }
  </script>

这里需要注意一点就是上面的detail是导航栏的类选择器的值(这里的class一定要一样)

整个页面代码

@{
 layout = null;
}

<!doctype html>

<html>
<head>
 <meta name="viewport" content="width=device-width" />
 <title>index</title>
 <script src="~/scripts/jquery-1.8.2.js"></script>
 <script src="~/content/easyui/jquery.easyui.min.js"></script>
 <script src="~/content/easyui/easyui-lang-zh_cn.js"></script>
 <link href="~/content/easyui/themes/default/easyui.css" rel="external nofollow" rel="stylesheet" />
 <link href="~/content/easyui/themes/icon.css" rel="external nofollow" rel="stylesheet" />
 <script type="text/javascript">
  $(function () {
   //tabs的点击事件
   bindtabsevent();
  });
  function bindtabsevent() {
   $(".detail").click(function () {
    //拿到点击标题
    var title = $(this).text();
    //拿到点击的url
    var url = $(this).attr("url");
    //判断标签是否存在
    var isext = $("#tt").tabs("exists", title);
    //如果存在则选中
    if (isext) {
     $("#tt").tabs("select", title); //选中
     return;
    }
    //不存在就添加标签
    $("#tt").tabs("add", {
     title: title,
     content: createtabcontent(url),
     closable:true
    });
   });
  }
  function createtabcontent(url) {
   return '<iframe src="' + url + '" scrolling="no" frameborder="0" width="100%" height="100%"></iframe>';
  }
 </script>
</head>
<body class="easyui-layout">
 <div data-options="region:'north',border:false" style="height:60px;background:#b3dfda;padding:10px">north region</div>

 <!---------左侧布局------------------------------------>

 <div data-options="region:'west',split:true,title:'west'" style="width:150px;padding:0px;">
  <div class="easyui-accordion" style="width:auto;height:auto;">

   <div title="新闻管理" data-options="iconcls:'icon-ok'" style="overflow:auto;padding:10px;">
    <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" class="detail" url="/adminnewinfo/index">新闻管理</a>
   </div>

   <div title="评论管理" data-options="iconcls:'icon-ok'" style="overflow:auto;padding:10px;">
    <a href="javascript:void(0)" rel="external nofollow" rel="external nofollow" class="detail" url="/commentinfo/index">评论管理</a>
   </div>


  </div>


 </div>

 <!---------左侧布局结束------------------------------------>


 <div data-options="region:'south',border:false" style="height:30px;background:#a9facd;padding:10px;">south region</div>


 <!--------------中间布局开始---------------->
 <div data-options="region:'center',title:'center'" >
  <div class="easyui-tabs" style="width:700px;height:250px" fit="true" id="tt">
   <div title="欢迎使用">
    <h1 style="font-size: 24px;">欢迎!</h1>
    <h1 style="font-size: 24px; color:red;"> welcome !</h1>
   </div>


  </div>

 </div>
 <!--------------中间布局结束--------------->

</body>
</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网