MVC+EasyUI+三層新聞網站建立 tabs標簽制作方法(六)
更新時間:2017年07月10日 16:30:50 作者:劉指導
這篇文章主要為大家詳細介紹了MVC+EasyUI+三層新聞網站建立的第六篇,教大家如何制作tabs標簽,具有一定的參考價值,感興趣的小伙伴們可以參考一下
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的點擊事件實現(xiàn)了
其實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>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
asp.net基于替換模版頁的形式生成靜態(tài)頁的方法
這篇文章主要介紹了asp.net基于替換模版頁的形式生成靜態(tài)頁的方法,涉及asp.net模板的設置、變量替換、配置文件設置與讀取、以及文件夾與靜態(tài)文件的創(chuàng)建等技巧,需要的朋友可以參考下2016-07-07
.NET5控制臺程序使用EF連接MYSQL數(shù)據(jù)庫的方法
這篇文章主要介紹了.NET5控制臺程序使用EF連接MYSQL數(shù)據(jù)庫,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-08-08

