Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-13-2011, 12:34 AM   PM User | #1
conelrad
New to the CF scene

 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
conelrad is an unknown quantity at this point
Question RSS Refresh Button

I need help with a javascript refresh button. I'm having trouble linking the feed fetcher section to the refresh button section.
I think code lines 81 through 87 are the problem.

[code]

// create table view data object
var data = [];

var xhr = Ti.Network.createHTTPClient();
xhr.open("GET","http://rss.news.yahoo.com/rss/business");
xhr.onload = function()
{
try
{
var doc = this.responseXML.documentElement;
var items = doc.getElementsByTagName("item");
var x = 0;
var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue;
for (var c=0;c<items.length;c++)
{
var item = items.item(c);
var thumbnails = item.getElementsByTagName("media:thumbnail");
var media;
if (thumbnails && thumbnails.length > 0)
{
media = thumbnails.item(0).getAttribute("url");

}
else
{
media="blue.png";
}

var title = item.getElementsByTagName("title").item(0).text;
var row = Ti.UI.createTableViewRow({height:80});
var label = Ti.UI.createLabel({
text:title,
left:72,
top:5,
bottom:5,
right:5
});
row.add(label);
var img;
if (Titanium.Platform.name == 'android')
{
// iphone moved to a single image property - android needs to do the same
img = Ti.UI.createImageView({
url:media,
left:5,
height:60,
width:60
});

}
else
{
img = Ti.UI.createImageView({
image:media,
left:5,
height:60,
width:60
});

}
row.add(img);
data[x++] = row;
row.url = item.getElementsByTagName("link").item(0).text;

}
var tableview = Titanium.UI.createTableView({data:data});
Titanium.UI.currentWindow.add(tableview);
tableview.addEventListener('click',function(e)
{
var d=Titanium.Platform.openURL(e.row.url);

});

// START REFRESH code
var refresh = Titanium.UI.createButton({
systemButton:Titanium.UI.iPhone.SystemButton.REFRESH
});
refresh.addEventListener('click', function()
{
tableview.Data([]);
setTimeout(function()
{
Data();
},1000);
});

if (Ti.Platform.name == 'iPhone OS') {
win2.rightNavButton = refresh;
} else {
refresh.top = 5;
refresh.title = "Refresh";
refresh.width = 200;
tableview.top = 60;
Titanium.UI.currentWindow.add(refresh);
}

Data();

//END REFRESH code

}
catch(E)
{
alert(E);
}


};
xhr.send();




[code]
conelrad is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, refresh, rss, titanium mobile

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:12 AM.


Advertisement
Log in to turn off these ads.