Titanium Community Questions & Answer Archive

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

Attaching function as property to view object works on iPhone, NOT on Android

I need to store a callback function in views and other objects so that I can fire async HTTPClient operations that can later call it to refresh images and texts.

I did something similar to the following, and it works perfectly on iPhone.

var myfun = function(param)    {
    Ti.API.info('Myfun called by ' + param);
};

var x = {fun:myfun};
x.fun('x');     // this always works 

var view = Ti.UI.createView({});
view.fun = myfun;
view.fun('view'); // this crashes on Android

Unfortunately Android crashes on last line with message "TypeError: Cannot call property fun in object ti.modules.titanium.ui.ViewProxy@4380b2c8. It is not a function, it is 'object'."

Any idea on how to convince Android that 'fun' is a function indeed?

Thanks

— asked October 7th 2010 by Mario Capocaccia
  • android
  • custom
  • property
0 Comments

1 Answer

  • Accepted Answer

    That may be working in a 1_4_X Continuous Integration Build. Instructions for using CI builds are in the Programming Guides section of the documentation.

    — answered October 7th 2010 by Don Thorp
    permalink
    1 Comment
    • Confirmed working on 1_4_X CI Build as of Oct 8.
      Thanks Don. M.

      — commented October 8th 2010 by Mario Capocaccia
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.