Titanium Community Questions & Answer Archive

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

fireEvent / addEventListener do not work for arbitrary objects?

If I fire my custom event with the following code:

Ti.API.fireEvent('foo', {bar:'baz'});

Then the only way to catch it is to use:

Ti.App.addEventListener('foo', function(e) { 
    /* this will work */
});

If i try to do this on an arbitrary window or view, the event won't be caught:

view.addEventListener('foo', function(e) { 
    /* we will never get here */
});

What gives? This kind of defeats the purpose of custom events.

I'm using iPhone SDK 3.1.3, Titanium 1.1.2.

— asked March 26th 2010 by Igor Afanasyev
  • events
  • fireevent
  • iphone
0 Comments

2 Answers

  • you must fire the event in the object that view references

    — answered April 16th 2012 by Ryan popa
    permalink
    0 Comments
  • Hello , this is My first POST , You must only Fire the event Like this

    Ti.App.fireEvent('foo',{data:'data'});

    — answered May 27th 2012 by Goro Dev
    permalink
    0 Comments
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.