Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

What am I doing wrong?

I've spent way too much time on this … I know I'm missing something very simple … I am trying to open a window when the user clicks on an entry in a tableView … I can't see or seem to open the window …

Here is a stripped down version of my app.js …

— asked March 21st 2010 by JD Hofer
  • iphone
  • mobile
  • tableview

4 Answers

  • Accepted Answer

    OK, so this is easy to see how you could miss this.

    The problem is that you're using Titanium.UI.currentTab in app.js. You can only use Titanium.UI.currentTab in the context of another opened window (called a sub-context) opened within a window with a url.

    So, for your example, just change Titanium.UI.currentTab to tab1.

    I realize this probably isn't intuitive initially. This special property is meant to give you a handle to the tab that you're parented to when opened inside a window.

    For example, if you did:

    var win = Ti.UI.createWindow({url:"foo.js"});

    then inside foo.js you'd be able to open another window in the tab:

    var win = Ti.UI.createWindow({url:"bar.js"});

    Hope that helps clarify.

    — answered March 21st 2010 by Jeff Haynie
    1 Comment
    • Thanks a lot!!!I have been troubled by this question very long time T.T

      — commented August 3rd 2011 by Sting Tao
  • Hi there,

    What might be an issue is adding the tableView to the window before setting the event listener. Once your code reaches line 15 it'll send objects to the screen.

    Try moving the click event function up to between 7 and 8.
    I find it easiest to keep event listeners right next to their creation commands, unless some other logic (mode) changes their behavior.


    — answered March 21st 2010 by Chris Reed
  • Chris, I think you've just solved a problem of my that has troubled me for many days. Could you please explain more in detail about the 15 line issue?

    — answered March 21st 2010 by William Xue
  • Chris … Thanks for your quick response … But that didn't do it :(

    — answered March 21st 2010 by JD Hofer
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.