jQuery EasyUi實(shí)戰(zhàn)教程之布局篇
jQuery EasyUI Layout是一種基于jQuery的布局框架,今天初次使用Jquery EasyUi,簡(jiǎn)單的做了個(gè)布局頁(yè)面感覺(jué)還不錯(cuò),給大家分享一下,就是不知道Jquery EasyUi瀏覽器兼容性怎么樣。
最后效果圖如下:
使用Jquery EasyUi開(kāi)發(fā)之前首先要引用Jquery EasyUi的Js和Css文件,引用如下:
<script src="../jquery.min.js" type="text/javascript"></script> <script src="../jquery.easyui.min.js" type="text/javascript"></script> <link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" /> <link href="../themes/icon.css" rel="stylesheet" type="text/css" />
OK,下面就開(kāi)始我們的布局。
一、使用布局面板進(jìn)行整體布局,直接貼代碼:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>LayOut</title> <script src="../jquery.min.js" type="text/javascript"></script> <script src="../jquery.easyui.min.js" type="text/javascript"></script> <link href="../themes/default/easyui.css" rel="stylesheet" type="text/css" /> <link href="../themes/icon.css" rel="stylesheet" type="text/css" /> <script language="JavaScript"> $(document).ready(function () { }); </script> <style> .footer { width: 100%; text-align: center; line-height: 35px; } .top-bg { background-color: #d8e4fe; height: 80px; } </style> </head> <body class="easyui-layout"> <div region="north" border="true" split="true" style="overflow: hidden; height: 80px;"> <div class="top-bg"></div> </div> <div region="south" border="true" split="true" style="overflow: hidden; height: 40px;"> <div class="footer">版權(quán)所有:<a >酷網(wǎng)工作室</a></div> </div> <div region="west" split="true" title="導(dǎo)航菜單" style="width: 200px;"> </div> <div id="mainPanle" region="center" style="overflow: hidden;"> </div> </body> </html>
以上代碼效果如下(完成局部第一步):
二、添加左側(cè)菜單
左側(cè)菜單使用的是jquery easyui的可伸縮面板控件和樹形控件的結(jié)合,直接將可伸縮面板控件和樹形控件放到west域中即可,并且編寫點(diǎn)擊事件,代碼如下:
頁(yè)面代碼:
<div region="west" split="true" title="導(dǎo)航菜單" style="width: 200px;"> <div id="aa" class="easyui-accordion" style="position: absolute; top: 27px; left: 0px; right: 0px; bottom: 0px;"> <div title="博文管理" iconcls="icon-save" style="overflow: auto; padding: 10px;"> <ul class="easyui-tree"> <li> <span>Folder</span> <ul> <li> <span>Sub Folder 1</span> <ul> <li> <span><a target="mainFrame" >審核博客</a></span> </li> <li> <span><a href="#">File 12</a></span> </li> <li> <span>File 13</span> </li> </ul> </li> <li> <span>File 2</span> </li> <li> <span>File 3</span> </li> </ul> </li> <li> <span><a href="#">File21</a></span> </li> </ul> </div> <div title="新聞管理" iconcls="icon-reload" selected="true" style="padding: 10px;"> content2 </div> <div title="資源管理"> content3 </div> </div> </div>
Js點(diǎn)擊事件代碼:
<script language="JavaScript"> $(document).ready(function () { $('.easyui-accordion li a').click(function () { var tabTitle = $(this).text(); var url = $(this).attr("href"); addTab(tabTitle, url); $('.easyui-accordion li div').removeClass("selected"); $(this).parent().addClass("selected"); }).hover(function () { $(this).parent().addClass("hover"); }, function () { $(this).parent().removeClass("hover"); }); function addTab(subtitle, url) { if (!$('#tabs').tabs('exists', subtitle)) { $('#tabs').tabs('add', { title: subtitle, content: createFrame(url), closable: true, width: $('#mainPanle').width() - 10, height: $('#mainPanle').height() - 26 }); } else { $('#tabs').tabs('select', subtitle); } tabClose(); } function createFrame(url) { var s = '<iframe name="mainFrame" scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>'; return s; } function tabClose() { /*雙擊關(guān)閉TAB選項(xiàng)卡*/ $(".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; }); } //綁定右鍵菜單事件 function tabCloseEven() { //關(guān)閉當(dāng)前 $('#mm-tabclose').click(function () { var currtab_title = $('#mm').data("currtab"); $('#tabs').tabs('close', currtab_title); }) //全部關(guān)閉 $('#mm-tabcloseall').click(function () { $('.tabs-inner span').each(function (i, n) { var t = $(n).text(); $('#tabs').tabs('close', t); }); }); //關(guān)閉除當(dāng)前之外的TAB $('#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); }); }); //關(guān)閉當(dāng)前右側(cè)的TAB $('#mm-tabcloseright').click(function () { var nextall = $('.tabs-selected').nextAll(); if (nextall.length == 0) { //msgShow('系統(tǒng)提示','后邊沒(méi)有啦~~','error'); alert('后邊沒(méi)有啦~~'); return false; } nextall.each(function (i, n) { var t = $('a:eq(0) span', $(n)).text(); $('#tabs').tabs('close', t); }); return false; }); //關(guān)閉當(dāng)前左側(cè)的TAB $('#mm-tabcloseleft').click(function () { var prevall = $('.tabs-selected').prevAll(); if (prevall.length == 0) { alert('到頭了,前邊沒(méi)有啦~~'); return false; } prevall.each(function (i, n) { var t = $('a:eq(0) span', $(n)).text(); $('#tabs').tabs('close', t); }); return false; }); //退出 $("#mm-exit").click(function () { $('#mm').menu('hide'); }) } });
以上代碼效果圖:
三、最后點(diǎn)擊菜單時(shí)需要在center域顯示點(diǎn)擊后的內(nèi)容頁(yè)面,代碼如下:
<div id="tabs" class="easyui-tabs" fit="true" border="false"> <div title="歡迎使用" style="padding: 20px; overflow: hidden;" id="home"> <h1>Welcome to jQuery UI!</h1> </div> </div>
本文已完到此結(jié)束。希望本文分享對(duì)大家有所幫助。
- jQuery Easyui使用(一)之可折疊面板的布局手風(fēng)琴菜單
- JQuery EasyUI Layout 在from布局自適應(yīng)窗口大小的實(shí)現(xiàn)方法
- jQuery Easyui實(shí)現(xiàn)左右布局
- jQuery EasyUI 布局之動(dòng)態(tài)添加tabs標(biāo)簽頁(yè)
- JQueryEasyUI Layout布局框架的使用
- Jquery組件easyUi實(shí)現(xiàn)手風(fēng)琴(折疊面板)示例
- Jquery組件easyUi實(shí)現(xiàn)選項(xiàng)卡切換示例
- Jquery組件easyUi實(shí)現(xiàn)表單驗(yàn)證示例
- jQuery EasyUI API 中文文檔 - DataGrid數(shù)據(jù)表格
- jQuery組件easyui基本布局實(shí)現(xiàn)代碼
相關(guān)文章
從零開(kāi)始學(xué)習(xí)jQuery (一) 開(kāi)天辟地入門篇
本篇文章是入門第一篇, 主要是簡(jiǎn)單介紹jQuery, 通過(guò)簡(jiǎn)單示例指導(dǎo)大家如何編寫jQuery代碼以及搭建開(kāi)發(fā)環(huán)境. 詳細(xì)講解了如何在Visual Studio中配合使用jQuery.2010-10-10jQuery的選擇器中的通配符[id^=''code'']或[name^=''code'']及jquery選擇器總結(jié)
這篇文章主要介紹了jQuery的選擇器中的通配符[id^='code']或[name^='code']及jquery選擇器總結(jié)的相關(guān)資料,需要的朋友可以參考下2015-12-12jquery手機(jī)觸屏滑動(dòng)拼音字母城市選擇器的實(shí)例代碼
下面小編就為大家分享一篇jquery手機(jī)觸屏滑動(dòng)拼音字母城市選擇器的實(shí)例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-12-12jquery異步循環(huán)獲取功能實(shí)現(xiàn)代碼
頁(yè)面html的repeater控件中有一個(gè)span,需要根據(jù)指定ID異步獲取相關(guān)信息。2010-09-09jQuery Ajax向服務(wù)端傳遞數(shù)組參數(shù)值的實(shí)例代碼
在使用MVC時(shí),向服務(wù)器端發(fā)送POST請(qǐng)求時(shí)有時(shí)需要傳遞數(shù)組作為參數(shù)值,下面通過(guò)實(shí)例代碼給大家介紹jQuery Ajax向服務(wù)端傳遞數(shù)組參數(shù)值的方法,一起看看吧2017-09-09基于jQuery插件實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖效果
這篇文章主要為大家詳細(xì)介紹了基于jQuery實(shí)現(xiàn)點(diǎn)擊小圖顯示大圖效果的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05jQuery實(shí)現(xiàn)基本動(dòng)畫效果的方法詳解
這篇文章主要介紹了jQuery實(shí)現(xiàn)基本動(dòng)畫效果的方法,結(jié)合實(shí)例形式分析了jQuery animate()方法實(shí)現(xiàn)動(dòng)畫效果相關(guān)操作技巧,需要的朋友可以參考下2018-09-09jQuery插件select2利用ajax高效查詢大數(shù)據(jù)列表(可搜索、可分頁(yè))
select2是一款jQuery插件,是普通form表單select組件的升級(jí)版。 接下來(lái)通過(guò)本文給大家介紹jQuery插件select2利用ajax高效查詢大數(shù)據(jù)列表(可搜索、可分頁(yè)),需要的的朋友參考下吧2017-05-05jquery實(shí)現(xiàn)回車鍵觸發(fā)事件(實(shí)例講解)
下面小編就為大家分享一篇jquery實(shí)現(xiàn)回車鍵觸發(fā)事件的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2017-11-11