jQuery EasyUI Application - Creating an RSS Feed Reader
In this tutorial, we will create an RSS reader using the jQuery EasyUI framework.
We will use the following plugins:
- layout: create the application's user interface.
- datagrid: display the RSS feed list.
- tree: display the feed channels.
Step 1: Create the layout (Layout)
jQuery EasyUI RSS Reader Demo
Title
Description
Publish Date
Step 2: DataGrid event handling
Here we handle some events triggered by the user.
$('#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);
}
}
});
This example uses the 'onSelect' event to display the feed content and the 'onLoadSuccess' event to select the first row.
Step 3: Tree menu event handling
When the tree menu data has loaded, we need to select the first leaf node and call the 'select' method to select that node. Use the 'onSelect' event to get the selected node so we can obtain the corresponding 'url' value. Finally, we call the DataGrid's 'load' method to refresh the feed list data.
$('#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);
}
}
});