輕松學(xué)習(xí)jQuery插件EasyUI EasyUI創(chuàng)建RSS Feed閱讀器
本文實(shí)例講述了通過 jQuery EasyUI框架創(chuàng)建一個(gè)RSS閱讀器,分享給大家供大家參考。具體如下:
運(yùn)行效果截圖如下:
我們將使用以下插件:
layout:創(chuàng)建應(yīng)用的用戶界面。
datagrid:顯示 RSS Feed 列表。
tree:顯示 feed 頻道。
步驟 1:創(chuàng)建布局(Layout)
<body class="easyui-layout"> <div region="north" border="false" class="rtitle"> jQuery EasyUI RSS Reader Demo </div> <div region="west" title="Channels Tree" split="true" border="false" style="width:200px;background:#EAFDFF;"> <ul id="t-channels" url="data/channels.json"></ul> </div> <div region="center" border="false"> <div class="easyui-layout" fit="true"> <div region="north" split="true" border="false" style="height:200px"> <table id="dg" url="get_feed.php" border="false" rownumbers="true" fit="true" fitColumns="true" singleSelect="true"> <thead> <tr> <th field="title" width="100">Title</th> <th field="description" width="200">Description</th> <th field="pubdate" width="80">Publish Date</th> </tr> </thead> </table> </div> <div region="center" border="false" style="overflow:hidden"> <iframe id="cc" scrolling="auto" frameborder="0" style="width:100%;height:100%"></iframe> </div> </div> </div> </body>
步驟 2:數(shù)據(jù)網(wǎng)格(DataGrid)處理事件
在這里我們要處理一些由用戶觸發(fā)的事件。
$('#dg').datagrid({ onSelect: function(index,row){ $('#cc').attr('src', row.link); }, onLoadSuccess:function(){ var rows = $(this).datagrid('getRows'); if (rows.length){ $(this).datagrid('selectRow',0); } } });
本實(shí)例使用 'onSelect' 事件來顯示 feed 的內(nèi)容,使用 'onLoadSuccess' 事件來選擇第一行。
步驟 3:樹形菜單(Tree)處理事件
當(dāng)樹形菜單(Tree)數(shù)據(jù)已經(jīng)加載,我們需要選擇第一個(gè)葉子節(jié)點(diǎn),調(diào)用 'select' 方法來選擇該節(jié)點(diǎn)。 使用 'onSelect' 事件來得到已選擇的節(jié)點(diǎn),這樣我們就能得到對應(yīng)的 'url' 值。 最后我們調(diào)用數(shù)據(jù)網(wǎng)格(DataGrid) 的 'load' 方法來刷新 feed 列表數(shù)據(jù)。
$('#t-channels').tree({ onSelect: function(node){ var url = node.attributes.url; $('#dg').datagrid('load',{ url: url }); }, onLoadSuccess:function(node,data){ if (data.length){ var id = data[0].children[0].children[0].id; var n = $(this).tree('find', id); $(this).tree('select', n.target); } } });
以上就是關(guān)于EasyUI創(chuàng)建RSS Feed閱讀器的相關(guān)教程,希望對大家的學(xué)習(xí)有所幫助。
相關(guān)文章
jQuery實(shí)現(xiàn)Twitter的自動(dòng)文字補(bǔ)齊特效
本文介紹了一款jQuery實(shí)現(xiàn)的文字自動(dòng)補(bǔ)全特效的插件,該插件可以結(jié)合本地?cái)?shù)據(jù)進(jìn)行一些操作。推薦關(guān)注一下H5的幾種數(shù)據(jù)存儲(chǔ)的方式(localstorage與sessionstorage、IndexedDB、離線緩存manifest文件)2014-11-11jQuery進(jìn)行組件開發(fā)完整實(shí)例
這篇文章主要介紹了jQuery進(jìn)行組件開發(fā)的方法,以完整實(shí)例形式分析了基于jQuery實(shí)現(xiàn)自定義組件的相關(guān)技巧,代碼備有詳盡的注釋便于理解,需要的朋友可以參考下2015-12-12jQuery事件綁定用法詳解(附bind和live的區(qū)別)
這篇文章主要介紹了jQuery事件綁定用法,結(jié)合實(shí)例形式較為詳細(xì)的分析了jQuery事件綁定的實(shí)現(xiàn)原理與相關(guān)注意事項(xiàng),并附帶了相關(guān)綁定方法的使用說明,重點(diǎn)介紹了bind和live的區(qū)別,需要的朋友可以參考下2016-01-01jQuery Ajax方法調(diào)用 Asp.Net WebService 的詳細(xì)實(shí)例代碼
我在這里將jQuery Ajax 調(diào)用Aspx.Net WebService 的幾個(gè)常用的方法做了一個(gè)整理,提供給正在找這方面內(nèi)容的博友,希望能給學(xué)習(xí)jQuery的朋友一點(diǎn)幫助,可以直接復(fù)制代碼運(yùn)行。2011-04-04jQuery動(dòng)態(tài)改變圖片顯示大小(修改版)的實(shí)現(xiàn)思路及代碼
這篇文章主要介紹了jQuery動(dòng)態(tài)改變圖片顯示大小(修改版)的實(shí)現(xiàn)思路及代碼,有需要的朋友可以參考一下2013-12-12