Titanium Community Questions & Answer Archive

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

Passing variables not working

I have a tableview in a window which is inside a tab. When an item is clicked i am creating a new window and i want to pass a function to this window.To pass the variable i have done exactly as this post http://developer.appcelerator.com/question/73131/passing-variables-between-pages suggests but when i call the function in the new window it just returns null.

Here is the entire code http://pastie.org/1313186

Please help. Thank you in advance

— asked November 20th 2010 by Ashok Varma Kucharlapati
  • mobile
  • passing
  • variables
1 Comment
  • Don't know if you're using Android or iPhone, but there's a bug in Android and Titanium 1.4 (which seems to be fixed in recent 1.5 snapshots).

    — commented November 20th 2010 by Etienne Bernard

3 Answers

  • shouldn't this

    window.getCategoryID = getCategoryID;
    

    be this

    window.getCategoryID = getCategoryID();
    
    — answered November 20th 2010 by Aaron Saunders
    permalink
    4 Comments
    • Well as i understand it, i am passing the reference to the function and not the variable and in category1.js i am calling the function. Also the post that i was pointing to does it the same way.

      Correct me if i am wrong. Thank you

      — commented November 20th 2010 by Ashok Varma Kucharlapati
    • but why? honestly I thing the correct thing is to just pass the variable, I suspect that will work and it is clearer

      window.getCategoryID = e.rowData.categoryID;
      

      — commented November 20th 2010 by Aaron Saunders
    • and the title is confusing, what you are trying to do here is pass a function reference to a new context and I am not even certain that will work

      — commented November 20th 2010 by Aaron Saunders
    • Have a look at the passing section in this page http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Window-object. Atleast according to this i should be able to pass functions and yes you are right what you suggest looks easier but doesnt work either.

      — commented November 21st 2010 by Ashok Varma Kucharlapati
  • Well as i understand it, i am passing the reference to the function and not the variable and in category1.js i am calling the function. Also the post that i was pointing to does it the same way.

    Correct me if i am wrong. Thank you

    — answered November 20th 2010 by Ashok Varma Kucharlapati
    permalink
    0 Comments
  • Don't know if you're using Android or iPhone, but there's a bug in Android and Titanium 1.4 (which seems to be fixed in recent 1.5 snapshots).

    (sorry for the previous comment, should have been an answer)

    — answered November 20th 2010 by Etienne Bernard
    permalink
    1 Comment
    • I am using android and thank you, i will try the 1.5 snapshots

      — commented November 20th 2010 by Ashok Varma Kucharlapati
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.