Skip to content

Instantly share code, notes, and snippets.

@tzhbami7
Created February 8, 2013 11:26
Show Gist options
  • Save tzhbami7/4738286 to your computer and use it in GitHub Desktop.
Save tzhbami7/4738286 to your computer and use it in GitHub Desktop.
der totale krieg!
unction RemoteWindow() {
var self = Ti.UI.createWindow({
title:"Load remote Data",
backgroundColor:'#fff'
});
var resultTbl = Ti.UI.createTableView({
separatorStyle: Titanium.UI.iPhone.TableViewSeparatorStyle.NONE
});
self.add(resultTbl);
//eventListener focus --> click
//
self.addEventListener('focus', function() {
xhr = Ti.Network.createHTTPClient();
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function() {
Titanium.API.info('API.INFO');
var data = JSON.parse(this.responseText);
for (var i=0; i < data.length; i++) {
var row = Ti.UI.createTableViewRow();
var test_img = Titanium.UI.createImageView({
url: "images/brown_bg_482.png",
width: 32,
height: 32,
left: 4
});
var test_lbl = Titanium.UI.createLabel({
text: data[i].title + " " + data[i].category_title
});
row.add(test_img);
row.add(test_lbl);
resultTbl.appendRow(row);
};
};
// open the client
xhr.open('GET','http://api.i-v-o.ch/assignments.json');
// send the data
xhr.send();
//resultTbl.setData([]);
//resultTbl.appendRow(row);
});
return self;
};
module.exports = RemoteWindow;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment