JQuery EasyUI 結(jié)合 zTree樹(shù)形結(jié)構(gòu)制作web頁(yè)面.easyui用起來(lái)比較簡(jiǎn)單,很好的封裝了jquery的部分功能,使用起來(lái)更加方便,但是從1.2.3版本以后,商業(yè)用途是需要付費(fèi)的,
zTree是國(guó)內(nèi)的大牛們搞的一個(gè)jquery樹(shù)形tree插件,感覺(jué)很好用,很強(qiáng)大,而且完全免費(fèi),API等做的也非常不錯(cuò).推薦
easyui 是一個(gè)基于 jQuery 的框架,集成了各種用戶界面插件。
easyui 提供建立現(xiàn)代化的具有交互性的 javascript 應(yīng)用的必要的功能。
使用 easyui,您不需要寫太多 javascript 代碼,一般情況下您只需要使用一些 html 標(biāo)記來(lái)定義用戶界面。
HTML 網(wǎng)頁(yè)的完整框架。
easyui 節(jié)省了開(kāi)發(fā)產(chǎn)品的時(shí)間和規(guī)模。
easyui 非常簡(jiǎn)單,但是功能非常強(qiáng)大。
需要的導(dǎo)入以下幾種js文件和樣式表
easyui/themes/default/easyui.csseasyui/themes/icon.css jquery-1.8.3.jseasyui/jquery.easyui.min.jsztree/jquery.ztree.all-3.5.js(該文件包括core,exhide,exedit,excheck)ztree/zTreeStyle.css<script type="text/javascript"> // ztree菜單設(shè)置 var zTreeObj, setting = { view: { selectedMulti: false }, // 添加編輯設(shè)置:修改樹(shù)節(jié)點(diǎn)名稱/刪除樹(shù)節(jié)點(diǎn) edit: { enable: true }, data: { simpleData: { enable: true } }, callback:{ onClick: zTreeOnClick } }; // 回調(diào)函數(shù):單擊事件 function zTreeOnClick(event, treeId, treeNode, clickFlag) { alert(treeNode.id + ", " + treeNode.name); var content = '<div style="width:100%;height:100% ;overflow:hidden;">' +'<iframe src="' +treeNode.url +'" scrolling="auto" style="width:100%;height:100%;border:0;"></iframe></div>'; if(treeNode.url != undefined && treeNode.url != ""){ // 當(dāng)centre中是否存在名稱為treeNode.name的tabs if($("#tt").tabs('exists',treeNode.name)){ $("#tt").tabs('select',treeNode.name); }else { $("#tt").tabs('add',{ title:treeNode.name, content:content, closable:true }) } }; event.preventDefault(); }; // 提供ztree樹(shù)形菜單數(shù)據(jù) zTreeNodes = [ {"id":1, "pId":0, "name":"海賊王"}, {"id":11, "pId":1, "name":"娜美", "url":"http://man.linuxde.net/"}, {"id":12, "pId":1, "name":"羅賓", "url":"http://www.baidu.com"}, {"id":13, "pId":1, "name":"漢庫(kù)克", "url":"http://www.google.cn/"}, { "id":2, "pId":0, "name":"父節(jié)點(diǎn) 2", "open":true}, {"id":21,"pId":2, "name":"葉子節(jié)點(diǎn) 2-1"}, {"id":22, "pId":2, "name":"葉子節(jié)點(diǎn) 2-2"}, {"id":23,"pId":2, "name":"葉子節(jié)點(diǎn) 2-3"}, {"id":3, "pId":0, "name":"父節(jié)點(diǎn) 3", "open":true}, {"id":31, "pId":3, "name":"葉子節(jié)點(diǎn) 3-1"}, {"id":32, "pId":3, "name":"葉子節(jié)點(diǎn) 3-2"}, {"id":33, "pId":3, "name":"葉子節(jié)點(diǎn) 3-3"} ]; // 3.生成樹(shù)形菜單 $(document).ready(function(){ zTreeObj = $.fn.zTree.init($("#tree"), setting, zTreeNodes); }); // 4.對(duì)象選項(xiàng)卡注冊(cè)右擊事件 $(document).ready(function(){ $("#tt").tabs({ onContextMenu:function(e,title,index){ // 阻止系統(tǒng)默認(rèn)的右擊事件 e.preventDefault(); $('#mm').menu('show', { left: e.pageX, top: e.pageY }); } }); }); // 獲取所選取的面板對(duì)象 $(document).ready(function(){ $("#tt").tabs({ // 獲取所選取的面板對(duì)象 onSelect : function(title,index ){ // 5. menu的單擊事件綁定 $("#mm").menu({ onClick:function(item){ alert(item.name); // 當(dāng)點(diǎn)擊關(guān)閉當(dāng)前選項(xiàng)卡時(shí) if(item.name==='current'){ $('#tt').tabs('close',title); // 當(dāng)點(diǎn)擊關(guān)閉其他選項(xiàng)卡時(shí) }else if(item.name === 'others'){ var tabs = $('#tt').tabs('tabs'); $(tabs).each(function(){ if($(this).panel('options').title != '消息中心' && $(this).panel('options').title != title){ $('#tt').tabs('close',$(this).panel('options').title); } }); // 當(dāng)點(diǎn)擊關(guān)閉所有選項(xiàng)卡時(shí) }else if(item.name === 'all'){ var tabs = $('#tt').tabs('tabs'); $(tabs).each(function(){ if($(this).panel('options').title != '消息中心'){ $('#tt').tabs('close',$(this).panel('options').title); } }); } } }); } }) }) </script>
新聞熱點(diǎn)
疑難解答
圖片精選