Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Creating the drill down click event

Hey guys..upon successfully logging into my app, you are taken to main.js where I make my tabGroup

var win         = Titanium.UI.currentWindow;
var url         = "http://localhost:8888/lineup.xml";
var tabGroup     = Titanium.UI.createTabGroup();

// create base UI tab and root window
var mainWin = Titanium.UI.createWindow({
    title:'Line-Up Training',
    backgroundColor:'#fff',
    tabBarHidden:true
});

var mainTab = Titanium.UI.createTab({
    title:'Line-Up Training',
    window:mainWin
});

var main_menu = Ti.UI.createTableView({
    style:Titanium.UI.iPhone.TableViewStyle.GROUPED
});
mainWin.add(main_menu);

// add tabs
tabGroup.addTab(mainTab); 
// open tab group
tabGroup.open();

I am loading an XML Doc that looks like this:
http://pastie.org/1219135

It is 3 levels deep. This is my XML Loading method. It adds the first group and displays fine (and I am assuming the second), however my click even doesn't seem to be working. It is located at the bottom of this method. I haven't added the third set of table groups yet, I just have the for loop sitting there, but I need to figure this part out first.

function loadXML(url)
{
    Ti.API.info('>>>> loading RSS feed '+url);
    xhr = Titanium.Network.createHTTPClient();
    xhr.open('GET',url);

    xhr.onload = function()
    {
        Ti.API.info('>>> got the feed! ... ');

        var xml = this.responseXML;
        // Find the channel element

        var category = xml.documentElement.getElementsByTagName("category");
        for (var i = 0; i < category.length; i++)
        {
            var categoryTitle = category.item(i).getAttribute("title");

            var row = Ti.UI.createTableViewRow({
                hasChild:true
            });

            var label = Ti.UI.createLabel({
                left:9,
                text: categoryTitle
            });
            row.add(label);
            main_menu.appendRow(row);

            var course = category.item(i).getElementsByTagName("course");
            for (var j = 0; j < course.length; j++)
            {
                var courseTitle = course.item(j).getAttribute("title");
                var subWin = Ti.UI.createWindow({
                    title:courseTitle
                });
                var subTable = Ti.UI.createTableView({
                    style:Titanium.UI.iPhone.TableViewStyle.GROUPED
                });
                var subRow = Ti.UI.createTableViewRow();
                var subLabel = Ti.UI.createLabel({
                    left:9,
                    text:courseTitle
                });
                subRow.add(subLabel);
                subTable.appendRow(subRow);
                subWin.add(subTable);

                var topic = course.item(j).getElementsByTagName("topic");
                for (var k = 0; k < topic.length; k++)
                {
                    var topicTitle = topic.item(k).getAttribute("title");
                }
            }

            row.addEventListener('click',function(e)
            {
                mainTab.open(subWin);
            });
        }
    };
    xhr.send();
}

loadXML(url);

Any ideas? Thanks!

— asked October 13th 2010 by Ronnie Swietek
  • click
  • down
  • drill
  • event
  • xml
0 Comments

2 Answers

  • I think I have a zindex issue. Its like there is something invisible over it maybe.. I dont know..

    — answered October 13th 2010 by Ronnie Swietek
    permalink
    0 Comments
  • I ended up adding the main.js file to the existing tabGroup in app.js. Upon login, I added that main.js to the tabGroup, set it as the active tab and then hid the tabBar and viola, the click functions worked. I am pretty sure their was some view or window blocking my input. Anyway this solution worked for me.

    — answered October 13th 2010 by Ronnie Swietek
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.