Hi.
I am using facebook albums to populate a gallery in my app.
When i parse my albums from my FB page and try to open the photo from my album in a new window nothing shows up. But when i click "back" then it opens the gallery in the window where i had my tableview.
I suppose i have done something wrong with the click event listners but i cant figure out what.
Anywho here is the code
var win = Ti.UI.currentWindow; win.showNavBar(); Titanium.UI.setBackgroundColor('#ffffff'); // Logo image view var logImage = Ti.UI.createImageView({ width : '320dp', height : 'auto', top : 10, bottom : 10, image : 'images/h-3.jpg' }); win.add(logImage); var artist ='lucyseven'; var url = "https://graph.facebook.com/" + artist + "/albums"; var table = Ti.UI.createTableView({ top: 10, bottom: 10, backgroundColor: 'transparent', separatorColor:'#eee', }); var tableData = []; var json, data, name, picture, description; var xhr = Ti.Network.createHTTPClient({ onload: function() { // Ti.API.debug(this.responseText); json = JSON.parse(this.responseText); for (i = 0; i < json.data.length; i++) { data = json.data[i]; row = Ti.UI.createTableViewRow({ height:'100dp', backgroundColor: '#050505', separatorColor:'#110000', }); var name = Ti.UI.createLabel({ text: data.name, font:{ fontSize:'17dp', fontWeight:'bold' }, height:'auto', left:'90dp', top:'20dp', color:'#eee', touchEnabled:true }); row.add(name); row.id = data.id; row.name = data.name; tableData.push(row); } table.setData(tableData); }, onerror: function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('There was an error retrieving the remote data. Try again.'); }, timeout:5000 }); xhr.open("GET", url); xhr.send(); // Handle a click event on the table table.addEventListener('click',function(e) { // Create the new window with the link from the post var faceWindow = Ti.UI.createWindow({ title : e.row.name, modal : true, barColor: '#050505', backgroundColor: '#050505' }); e.row.id; // Create our HTTP Client and name it "loader" var loader = Titanium.Network.createHTTPClient(); // Runs the function when the data is ready for us to process loader.onload = function() { var data = JSON.parse(this.responseText); var images = []; for (var c=0;c<data.data.length;c++) { images[c]= {image: data.data[c].source, heigth:'100%'}; } // create coverflow view with images var view = Titanium.UI.iOS.createCoverFlowView({ images:images, backgroundColor:'#000', top: '2', bottom: '2', left: '2', right: '2' }); win.add(view); // click listener - when image is clicked view.addEventListener('click',function(e) {//<<<---this is the convertFlowView // the window to place the image in var imgWindow = Ti.UI.createWindow({ modal: true, barColor: '#050505', backgroundColor: '#050505' }); // The new image view to place the selected image var fullImage = Ti.UI.createWebView({ html: '<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2, user-scalable=yes" /><img src="'+ images[e.index].image + '" / Width="100%">', backgroundColor: '#050505' }); // Create a button to close the modal window var close_modal = Titanium.UI.createButton({title:'Stäng'}); imgWindow.rightNavButton = close_modal; // Handle close_modal event close_modal.addEventListener('click', function() { imgWindow.close(); }); // Add the views to the window and open it imgWindow.add(fullImage); imgWindow.open(); }); } // From where i get my photos var url = "https://graph.facebook.com/" + e.row.id + "/photos"; loader.open("GET", url); // Send the HTTP request loader.send(); // Create the close button to go in the left area of the navbar popup var close = Titanium.UI.createButton({ title: 'Back', style: Titanium.UI.iPhone.SystemButtonStyle.PLAIN }); faceWindow.setLeftNavButton(close); // Handle the close event close.addEventListener('click',function() { faceWindow.close(); }); faceWindow.open(); }); win.add(table); win.open();Thanx
//R
1 Answer
Yepp! I did it all by myself.
i just did like this
table.addEventListener('click',function(e) { // Create the new window with the link from the post var faceWindow = Ti.UI.createWindow({ title : e.row.name, data: e.row.id, url: 'gallview.js', barColor: '#050505', backgroundColor: '#050505' });and then in gallview.js
var url = "https://graph.facebook.com/" + win.data + "/photos";Hope this helps someone else that is new to this.
//R
Your Answer
This question has been locked and cannot accept new answers.