輕松學習jQuery插件EasyUI EasyUI創(chuàng)建RSS Feed閱讀器
本文實例講述了通過 jQuery EasyUI框架創(chuàng)建一個RSS閱讀器,分享給大家供大家參考。具體如下:
運行效果截圖如下:

我們將使用以下插件:
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);
}
}
});
本實例使用 'onSelect' 事件來顯示 feed 的內(nèi)容,使用 'onLoadSuccess' 事件來選擇第一行。
步驟 3:樹形菜單(Tree)處理事件
當樹形菜單(Tree)數(shù)據(jù)已經(jīng)加載,我們需要選擇第一個葉子節(jié)點,調(diào)用 'select' 方法來選擇該節(jié)點。 使用 'onSelect' 事件來得到已選擇的節(jié)點,這樣我們就能得到對應(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)教程,希望對大家的學習有所幫助。
相關(guān)文章
jquery判斷checkbox是否選中及改變checkbox狀態(tài)的實現(xiàn)方法
下面小編就為大家?guī)硪黄猨query判斷checkbox是否選中及改變checkbox狀態(tài)的實現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-05-05
基于jquery的下拉框改變動態(tài)添加和刪除表格實現(xiàn)代碼
以前很少用jquery,現(xiàn)在工作需要,用上了,感覺真的很方便!不用再像以前那樣寫那么多多余的Js了!看來得在jquery上花點功夫呢!2011-03-03
基于jQuery的ajax功能實現(xiàn)web service的json轉(zhuǎn)化
前面文章說過下次會給大家介紹詳細的基于web Services的JqueryAjax調(diào)用如何把一個datatable得數(shù)據(jù)轉(zhuǎn)化成JSON數(shù)據(jù),然后在客戶端再通過json2.js轉(zhuǎn)化成javascript對象。2009-08-08
基于Jquery的動態(tài)添加控件并取值的實現(xiàn)代碼
基于Jquery的動態(tài)添加控件并取值的實現(xiàn)代碼,需要的朋友可以參考下。2010-09-09

