Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//Placed in /lib/functions.js
var getData = function(callback){
var rssFeed = Ti.Network.createHTTPClient();
rssFeed.onload = function(){
var xml = this.responseXML;
var items = xml.documentElement.getElementsByTagName("item");
var _title = "";
var tableData = [];
var row = "";
var rowLbl = "";
for(var i =0; i < items.length; i++)
_title = items.item(i).getElementsByTagName("title").item(0).textContent;
//create row
row = Ti.UI.createTableViewRow({
height: Ti.UI.SIZE,
guid: _guid
//create label for row
rowLbl = Ti.UI.createLabel({
text: _title,
textAlign: "center"
//add label to row
//add row to tableData array
//call callback function, pass data
rssFeed.onerror = function(e){"Error getting data from URL: "+JSON.stringify(e));
};"GET", "");
exports.getData = getData;
var functions = require('functions');
var tblView = Ti.UI.createTableView({
backgroundColor: "red"
//call getdata, passing callback function
$.btn_refresh.addEventListener('click', function(){
functions.getData(function(data){ = data;
//add table view to window
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment