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
0 Comments

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
    permalink
    0 Comments
  • did you file this in lighthouse?
    https://appcelerator.lighthouseapp.com/dashboard

    rocksteady,
    danno~

    — answered April 24th 2010 by danno watts
    permalink
    0 Comments
  • 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
    permalink
    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?
      Cheers
      Hal

      — 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.