Created
August 25, 2009 03:19
-
-
Save davidhemphill/174417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = function() | |
{ | |
var xhr1 = Titanium.Network.createHTTPClient(); | |
var xhr2 = Titanium.Network.createHTTPClient(); | |
var callOne = false; | |
var callTwo = false; | |
var section1 = null; | |
var section2 = null; | |
// create section1 here | |
xhr1.onload = function() | |
{ | |
callOne = true; | |
if (callTwo == true) | |
{ | |
// convert the response JSON text into a JavaScript object | |
var json = eval('(' + xhr1.responseText + ')'); | |
// pull out the current_series property which should return an array of rows | |
current = json['current_series']; | |
// createSection | |
section1 = Titanium.UI.iPhone.createGroupedSection({header:'Current Series', type:'option', data:current}); | |
buildGroupedView() // custom function | |
} | |
}; | |
xhr1.open("GET", "http://lebanonfamilychurch.org/mobile/current_series/"); | |
xhr1.send(null); | |
// create section2 here | |
xhr2.onload = function() | |
{ | |
callTwo=true; | |
if (callOne == true) | |
{ | |
// convert the response JSON text into a JavaScript object | |
var json = eval('(' + xhr2.responseText + ')'); | |
// pull out the more property which should return an array of rows | |
more = json['more']; | |
// createSection | |
section2 = Titanium.UI.iPhone.createGroupedSection({header:'More Series', type:'option', data:more}); | |
buildGroupedView() // custom function | |
} | |
}; | |
xhr2.open("GET", "http://lebanonfamilychurch.org/mobile/message_series/"); | |
xhr2.send(null); | |
function buildGroupedView() | |
{ | |
if (callOne==true && callTwo==true) | |
{ | |
// createGroupedView | |
var groupedView = Titanium.UI.iPhone.createGroupedView(); | |
/* Add sections to the view */ | |
groupedView.addSection(currentSection); | |
groupedView.addSection(seriesSection); | |
/* Add view to window */ | |
Titanium.UI.currentWindow.addView(groupedView); | |
/* Show the view */ | |
Titanium.UI.currentWindow.showView(groupedView); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment