Pass variable

You must Login before you can answer or comment on any questions.

Hi Team,

I have a question, please Could the team help to me?

I have a function that get the value of the xml a put the info in a array

(function () {
    MyApp.ui.createAboutWindow = function () {
        var aboutWindow = Titanium.UI.createWindow({
            id: 'aboutWindow',
            title: 'yyyyyy',
            backgroundColor: '#fff',
            barColor:'#00497c',
            navBarHidden: false,
            fullscreen: false,
            backgroundImage: Icrepes.ui.mainBackgroundImage        
        });
 
    var data = [];
 
    var xhr = Ti.Network.createHTTPClient();
 
    xhr.timeout = 1000000;
    xhr.open("GET", "http://www.yyyyyyyyy.com/file.xml");
    xhr.onload = function(){
    try {
            var doc = this.responseXML.documentElement;
            var items = doc.getElementsByTagName("item");
            var url = "http://www.webctsolutions.com/crepes/";
            var cont = 0;
 
            for (var c = 0; c < items.length; c++) {
 
                var thumbnail = "";
                var name = "";
                var item = "";
                var product_id = "";
                var title = "";
                var description = "";
                var price = "";
 
                item = items.item(c);
 
                product_id = item.getElementsByTagName("product_id").item(0).text;
                title = item.getElementsByTagName("title").item(0).text;
                description = item.getElementsByTagName("description").item(0).text;
                thumbnail = item.getElementsByTagName("thumbnail").item(0).text;
                price = item.getElementsByTagName("price").item(0).text;    
 
                thumbnail = replaceAll(thumbnail," ","%20");
 
                name = url + thumbnail;
                data[cont++] = {image:name, productId:product_id, title:title, description:description, price:price};
 
            }
        aboutWindow.add(view);
 
        }
        catch(e) 
        {   
            alert(E); 
        }
        };
 
        xhr.send();
 
        return aboutWindow;
   }
 
})();
2. The value of the data array is assigned to CoverFlow:
var view = Titanium.UI.createCoverFlowView({
    images:data,
    backgroundColor:'transparent'
});
3. In this point i do not have problem, because the all images is open in a cover flow. 4. Now, i need make click over a specific image, get the information (title, product_id,etc) and transfer to other windows:
view.addEventListener('click',function(e)
{
 
    Ti.API.info("image clicked: "+e.index+', selected is '+view.selected );
    Ti.API.debug(e.rowData.title);            
 
    MyApp.navGroup.open(MyApp.ui.createProductDetailWindow({
                    title: e.rowData.title,
                    productId: e.rowData.product_id,
                    image: e.rowData.image
                }), {
                    animated: true
                });
 
 
            });
);
Now the problem is that i cannot access to specific value of data array:
message = "Result of expression 'e.rowData' [undefined] is not an object.";
Are you suggestions for solve it, i am crazy found options?

Regards Jorge

1 Answer

Accepted Answer

Hi Jorge,

Try after replacing this code at view click event.

view.addEventListener('click',function(e)
{
 
  Ti.API.info("image clicked: "+e.index+', selected is '+view.selected );
  Ti.API.debug(e.rowData.title);            
 
 MyApp.navGroup.open(MyApp.ui.createProductDetailWindow({
                    title: e.rowData.title,
                    productId: data[e.index].product_id,
                    image: data[e.index].image
                }), {
                    animated: true
                });
 
            });    
);

Your Answer

Think you can help? Login to answer this question!