Titanium Community Questions & Answer Archive

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

[BUG] Ti.App.fireEvent() expects a string as the second arg on iPhone, and an object on Android

Using fireEvent() to send messages to a web view which is listening to the events. The events weren't being delivered on iPhone until I manually JSON.stringify()ed the second arg.

Edit: actually, even if I pass a string in to fireEvent(), the event listener only receives a single arg of the form {type: "theEventName"}. So am I right that passing data to a web view is just not possible on the iPhone at the moment apart from with evalJS hacks?

— asked April 23rd 2010 by Damien Elmes
  • bug
  • iphone

3 Answers

  • I dove into the titanium_mobile source code and figured it out. The problem is that function attributes are not stripped from the object before they are jsonified, so if the object has any prototype-inherited methods, invalid json is generated.

    [DEBUG] fire app event: showQuestion with {
    "__repr__" = <KrollCallback: 0x527e050>;
    question = "foo";
    [DEBUG] json str={"type":"showQuestion","question":"foo","__repr__":}
    — answered April 24th 2010 by Damien Elmes
  • did you file this in lighthouse?


    — answered April 24th 2010 by danno watts
  • When I asked marshall_law on IRC where I should file bugs, he told me to file them here.

    — answered April 24th 2010 by Damien Elmes
    1 Comment
    • Damien
      Is this still an issue? If you have raised a bug on lighthouse (which you ought to have done if you want it to be fixed) then would you post the ticket number here, please?

      — commented October 6th 2010 by Paul Dowsett
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.