mobile, 2.1, iOS, iOS sim, OSX 1.7.4, Titanium Studio, build: 2.1.0.201206251749
Problem:
I've got a tableviewrow with a label inside. When I click the row I pop up a datepicker. below that row I can go to a new page. When I come back from that page the click no longer works. Ideas?
1 Answer
This is highly stripped down, but produces the same behavior. Click all the way to page 3, then hit the back button, and try to click on Year. If you hit the Year first time around, no prob.
app.js
var MyApp = {}; MyApp.UI = {}; MyApp.Session = {}; MyApp.Session.ExampleFromDB = 2012; Ti.include( 'page1.js' , 'page2.js' , 'page3.js' , 'window.js' ); MyApp.Window.Open(MyApp.UI.Page1.View, 'Page 1');window.js
(function(){ MyApp.Window = {}; MyApp.Window.CurrentView = null; MyApp.Window.Open = function(view, title) { MyApp.Window.CurrentView = view; MyApp.Window.MainWindow = Ti.UI.createWindow({ backgroundColor: '#E5E5E5' , title: title }); MyApp.Window.MainWindow.add(MyApp.Window.CurrentView); if (MyApp.Window.TabGroup == null) { MyApp.Window.MainTab = Titanium.UI.createTab({ title: 'Main' , window: MyApp.Window.MainWindow , active: true }); MyApp.Window.TabGroup = Titanium.UI.createTabGroup(); MyApp.Window.TabGroup.addTab(MyApp.Window.MainTab); MyApp.Window.TabGroup.open(); MyApp.Window.TabGroup.setActiveTab(MyApp.Window.MainTab); } else { MyApp.Window.MainTab.open(MyApp.Window.MainWindow, {animated: true}); } }; MyApp.Window.ReloadView = function() { MyApp.Window.MainWindow.remove(MyApp.Window.CurrentView); MyApp.Window.CurrentView.fireEvent('loadView'); MyApp.Window.MainWindow.add(MyApp.Window.CurrentView); }; })();page1.js
(function(){ MyApp.UI.Page1 = {}; // -------------------------------------------------------------------------- MyApp.UI.Page1.View = Ti.UI.createView({ width: Ti.UI.FILL , height: Ti.UI.FILL }); // -------------------------------------------------------------------------- var table = Ti.UI.createTableView({ scrollabe: true , style: Ti.UI.iPhone.TableViewStyle.GROUPED }); var sections = []; /* Link to page 2 */ { var section = Ti.UI.createTableViewSection(); var row = Ti.UI.createTableViewRow({ height: 45 , hasChild: true }); var label = Ti.UI.createLabel({ text: 'Go to Page 2' , font: { fontSize: 15, fontWeight: 'bold' } , top: 15 , bottom: 15 , left: 15 , right: 45 , width: (Ti.Platform.displayCaps.platformWidth - 60) }); row.addEventListener('click', function(e) { MyApp.Window.Open(MyApp.UI.Page2.View, 'Page 2'); }); row.add(label); section.add(row); sections.push(section); } table.setData(sections); MyApp.UI.Page1.View.add(table); })();page2.js
(function(){ MyApp.UI.Page2 = {}; // -------------------------------------------------------------------------- MyApp.UI.Page2.View = Ti.UI.createView({ width: Ti.UI.FILL , height: Ti.UI.FILL }); // -------------------------------------------------------------------------- var table = Ti.UI.createTableView({ scrollabe: true , style: Ti.UI.iPhone.TableViewStyle.GROUPED }); var sections = []; /* Date Selector */ { var section = Ti.UI.createTableViewSection(); var row = Ti.UI.createTableViewRow({ height: 45 , hasChild: true , layout: 'horizontal' , horizontalWrap: true }); var labelTitle = Ti.UI.createLabel({ text: 'Year' , font: { fontSize: 15, fontWeight: 'bold' } , top: 15 , bottom: 15 , left: 10 , width: ((Ti.Platform.displayCaps.platformWidth - 30) * .5) - 15 , height: 15 }); var labelValue = Ti.UI.createLabel({ text: MyApp.Session.ExampleFromDB , font: { fontSize: 13, fontWeight: 'normal' } , top: 15 , bottom: 15 , left: 15 , width: ((Ti.Platform.displayCaps.platformWidth - 30) * .5) - 25 , height: 15 }); row.add(labelTitle); row.add(labelValue); row.addEventListener('click', function(e) { var years = [2012,2011,2010,2009,2008,2007]; var picker = Ti.UI.createPicker({ selectionIndicator: true , bottom: 0 }); var selectedIndex = 0; for (var i = 0; i < years.length; i++) { var pickerRow = Ti.UI.createPickerRow({ title: years[i].toString() }); if (years[i] == MyApp.Session.ExampleFromDB) { selectedIndex = i; } picker.add(pickerRow); } var releaseView = Ti.UI.createView({ height: Ti.UI.FILL }); releaseView.addEventListener('click', function(e) { MyApp.Session.ExampleFromDB = picker.getSelectedRow(0).title; MyApp.Window.ReloadView(); }); MyApp.Window.MainWindow.add(releaseView); MyApp.Window.MainWindow.add(picker); picker.setSelectedRow(0, selectedIndex, true); }); section.add(row); sections.push(section); } /* Link to page 2 */ { var section = Ti.UI.createTableViewSection(); var row = Ti.UI.createTableViewRow({ height: 45 , hasChild: true }); var label = Ti.UI.createLabel({ text: 'Go to Page 3' , font: { fontSize: 15, fontWeight: 'bold' } , top: 15 , bottom: 15 , left: 15 , right: 45 , width: (Ti.Platform.displayCaps.platformWidth - 60) }); row.addEventListener('click', function(e) { MyApp.Window.Open(MyApp.UI.Page3.View, 'Page 3', true, null); }); row.add(label); section.add(row); sections.push(section); } table.setData(sections); MyApp.UI.Page2.View.add(table); })();page3.js
(function(){ MyApp.UI.Page3 = {}; // -------------------------------------------------------------------------- MyApp.UI.Page3.View = Ti.UI.createView({ width: Ti.UI.FILL , height: Ti.UI.FILL }); // -------------------------------------------------------------------------- var table = Ti.UI.createTableView({ scrollabe: true , style: Ti.UI.iPhone.TableViewStyle.GROUPED }); var sections = []; /* page 3 row */ { var section = Ti.UI.createTableViewSection(); var row = Ti.UI.createTableViewRow({ height: 45 , hasChild: false }); var label = Ti.UI.createLabel({ text: 'Just Page 3' , font: { fontSize: 15, fontWeight: 'bold' } , top: 15 , bottom: 15 , left: 15 , right: 45 , width: (Ti.Platform.displayCaps.platformWidth - 60) }); row.add(label); section.add(row); sections.push(section); } table.setData(sections); MyApp.UI.Page3.View.add(table); })();
Your Answer
Think you can help? Login to answer this question!