Skip to content

Instantly share code, notes, and snippets.

@davidhemphill
Created August 25, 2009 03:19
Show Gist options
  • Save davidhemphill/174417 to your computer and use it in GitHub Desktop.
Save davidhemphill/174417 to your computer and use it in GitHub Desktop.
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