开发者

Working With Feeds and Lists

I'm using a ListView component to list up some informations at a RSS feed, but when the user clicks the row, I want to change into a detailed view of that RSS Item, so far I've done this:

开发者_运维知识库
function parseFeed(feed) {
    var html = "";

    for(var i = 0; i < feed.items.length && i < 5; i++) {
        var item = feed.items[i];
        var title = item.title;

        html += "\n<li onClick='goDetailed()'>\n";
        html += "<h3><a href='#' class='ui-link-inherit'>" + title + "</a></h3>\n";
        html += "<p>" + item.description + "</p>\n";
        html += "</li>";
    }

    $("#dList").append(html);
    $("#dList").listview('refresh');
}

function goDetailed() {
    $.mobile.changePage($('#detailedPage'));
}

One of my problems is that the Back button won't come back(it does nothing). My other question is how I can pass the item.title, item.description, item.link and item.updated of the selected row(feed item) to some <div data-role="content">'s at the detail page.


** to answer one of your questions when you press back it isn't affecting the javascript that is running and therefore would not change it back... try reload. If you look at your source you probably wont even see the content from the feed as it is done after the page's HTML is loaded in and parsed.

pass "i" on into the onclick function. When you click on that li

for(var i = 0; i < feed.items.length && i < 5; i++) {
    var item = feed.items[i];
    var title = item.title;

    html += "\n<li onClick='goDetailed("i")'>\n";
    html += "<h3><a href='#' class='ui-link-inherit'>" + title + "</a></h3>\n";
    html += "<p>" + item.description + "</p>\n";
    html += "</li>";
}

and when you write goDetailed(feedNumber) you can use which RSS feed item you clicked on easily.

function goDetailed(feedNumber) {
$.mobile.changePage($('feedNumber'));
}

so if you were to click on the 3rd item it would pass 2 (as in 0,1,2).

Hope this helps

EDIT 2

Actually this is what you're looking for!

Send the 'i' like I said above into the goDetailed and in the go detailed drop in what you are looking for.

function goDetailed(feedNumber) {

  newhtml += "<div data-role='content'>"feed.items[feedNumber].description"</div>";

 }

And that should select the proper feed item.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜