Reputation: 1078
I'm developing an iPhone app at the moment using Appcelerator Titanium which has 3 tabs in a tab group.
My app.js can be found here: http://pastie.org/private/zoignwv05l9t6pbrfm01dw
In the 'Company Search' tab group, I've been working on a Table View which loads data using an XHR keyword search (I've added a search box using Titanium.UI.createSearchBar with various event handlers for changing search, cancelling search). We'll call the first search results table view tier 1.
The search part works fine and I've set up a click event for the table view which works perfectly, opening a new window. We'll call this tier 2.
The problem is that if I click on the back button on tier 2 (returning me to my tier 1 results) and modify my search to something new, a new XHR request is made to refresh the table view data. If I then click one of these new results, the tier 2 window opens, but I can see a duplicated tier 2 window beneath it. Clicking the back button on the new tier 2 window takes me up the window hierachy to a duplicated tier 2 window.
It's almost as if when back is clicked on tier 2, the window is animated out of view but not removed (as I would expect).
I hope this makes sense. It's hard to describe.
Here's my company-search.js tab code: http://pastie.org/private/jdwiuasivd3zrnhcqbqxw
I've also got a video showing the problem: http://www.youtube.com/watch?v=1_1zlXf__UE
Thanks so much in advance for any ideas or recommendations.
Upvotes: 1
Views: 3718
Reputation: 1078
I've fixed this problem.
Here is my amended source code: http://pastie.org/private/ycown2e6tracfvdukz29uw
From what I work out, I appeared to be adding the table view to the current window every time the first XHR request was called.
I moved the table view row click event code and the win.add(tableView) code outside the loader.onload event code and hey-presto, it all works as planned!
Hope this helps someone else out.
Upvotes: 2
Reputation: 1871
It looks like the issue posted in Appcelerator forums. In company_search.js try checking e.rowData.url in the tableViews click event against the e.rowData.url from the previous click event. If it is same, do not open the window in the current tab.
Upvotes: 1