Can anyone help me, I create a scrollableview using json, everything works fine, but when I tried to add an event listener to create a new window on each view, only the final url on my json file is taken, and I can´t figure out how to specify an url for each view that is contained in the same json file.
Here is the .js
var win = Ti.UI.currentWindow; Titanium.App.fireEvent('CloseWin2'); // PRELOADER Ti.include('TiPreloader.js'); // Show the Preloader in favored window (here: win) and define the text which is displayed at the bottom of the preloader showPreloader(win,'Descargando ...'); var viewBarraUp = Ti.UI.createView({ backgroundColor:'#000' });//TOP //TOP VIEW & MENÚ var viewBarraUp = Titanium.UI.createView({//Top container top:0, left:0, height:62, width:1024, backgroundColor:'transparent', backgroundImage:'img/barraUp.png', zIndex:1 }); var AbriendoMenu = Titanium.UI.createButton({ title: '', top:21, //Remember: these postions are relative to the PARENT container right:15, //Remember: these postions are relative to the PARENT container width:27, height:21, backgroundImage :'img/Menu.png', backgroundSelectedImage:'img/MenuOver.png', }); // AbriendoMenu.addEventListener('click', function() { var openMenu = Titanium.UI.createWindow({ url:'menu.js', title:'New Window', backgroundColor:'transparent', top:0, navBarHidden:true }); openMenu.open({animated:true}); }); // viewBarraUp.add(AbriendoMenu); // INICIO JSON var url = "http://www.statusmexico.com/app/json/destacados.txt"; var images = []; var json, destacadosScroll, TitSecc, TitURL, container_view, i, image_url, image_view, image_Listener, image_btn; var xhr = Ti.Network.createHTTPClient({ onload: function() { // Ti.API.debug(this.responseText); json = JSON.parse(this.responseText); // TÍTULO DE LA SECCIÓN TitSecc = Titanium.UI.createImageView({ image: json.TitURL, top:4, left:302, width:420, height:54, preventDefaultImage: true }); viewBarraUp.add(TitSecc); for (i = 0; i < json.destacadosScroll.length; i++) { container_view = Ti.UI.createView(); image_url = json.destacadosScroll[i].imageurl; image_view = Ti.UI.createImageView({ image:image_url, top:0, left:0, right:0, bottom:0, preventDefaultImage: true }); image_btn = json.destacadosScroll[i].imageBtn; image_view.addEventListener('click', function() { var AbriendoH = Titanium.UI.createWindow({ url:image_btn, title:'New Window', backgroundColor:'transparent', top:0, navBarHidden:true }); AbriendoH.open({animated:true}); }); container_view.add(image_view); images.push(container_view); } var imageGallery = Titanium.UI.createScrollableView({ views:images, showPagingControl:true, backgroundColor:"#000", pagingControlColor:'#000', pagingControlOnTop:false, top:0, height:768 }); win.add(imageGallery);/// fin }, onerror: function(e) { Ti.API.debug("STATUS: " + this.status); Ti.API.debug("TEXT: " + this.responseText); Ti.API.debug("ERROR: " + e.error); alert('Al parecer no hay conexión a internet, ingresa más tarde.'); }, timeout:5000 }); xhr.open("GET", url); xhr.send(); setTimeout(function() { hidePreloader(win); }, 2000); win.add(viewBarraUp); win.open();Here is the json.txt
{ "TitURL": "http://www.statusmexico.com/app/titulos/TitSecc_DESTACADOS.png", "destacadosScroll": [ { "imageurl": "http://www.statusmexico.com/app/59/destacados/ImgDestadados.jpg", "imageBtn": "homeseccion.js" }, { "imageurl": "http://www.statusmexico.com/app/59/destacados/ImgDestadados_2.jpg", "imageBtn": "otraseccion.js" }, { "imageurl": "http://www.statusmexico.com/app/59/destacados/ImgDestadados_3.jpg", "imageBtn": "homeseccion.js" }, { "imageurl": "http://www.statusmexico.com/app/59/destacados/ImgDestadados_4.jpg", "imageBtn": "homeseccion.js" }, { "imageurl": "http://www.statusmexico.com/app/59/destacados/ImgDestadados_5.jpg", "imageBtn": "homeseccion.js" }, { "imageurl": "http://www.statusmexico.com/app/59/destacados/ImgDestadados_6.jpg", "imageBtn": "homeseccion.js" } ] }