W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
在本節(jié)內(nèi)容中,我們將介紹如何使用jQuery EasyUI框架來創(chuàng)建一個RSS Feed閱讀器。
以下是我們將會使用到的插件以及相應(yīng)的作用介紹:
<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>
在這個步驟中,我們要處理一些由用戶觸發(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'事件來選擇第一行。
當(dāng)樹形菜單(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);
}
}
});
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: