Titanium Community Questions & Answer Archive

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

e.source is always empty

I'm trying to access e.source in a 'change' eventListener for a textField, but e.source just returns an empty object. What am I missing?

Ti.API.info('e.source: '+JSON.stringify(e.source)); //prints 'e.source: {}'
— asked November 2nd 2010 by Charlie Rosenbury
  • eventlistener
  • textfield

3 Answers

  • Accepted Answer

    Try to set another value, not 'id', it may be used by titanium.

    It should work, and on change read this property, maybe something like


    — answered November 2nd 2010 by Dan Tamas
    1 Comment
    • Good call! Thanks.

      — commented November 2nd 2010 by Charlie Rosenbury
  • I'm not sure you can do it the way you are trying.
    If you put an alert you will get something like "[object TiUITab]"

    What exactly do you need?

    — answered November 2nd 2010 by Dan Tamas
  • Well, I have the textField inside of a tableViewRow. Each tableViewRow is associated with an ID that corresponds to a row in a database. The textField value corresponds with the db row's value. So whenever someone changes the textField, I'd like to update the database with the new value.

    However, using only the 'change' event to trigger the db update, I can't get the ID of the row. I'm currently trying to get around this by setting a 'currentFieldID' variable whenever someone clicks the row (which in turn focuses the textField) and then referencing that variable whenever the textField is changed. This is unreliable, though, as clicking another row will sometimes fire it's 'click' event before the textField's 'blur' event, resulting in the wrong db row getting updated.

    Ideally, I'd like to set an 'id' property on the textField itself whenever it's created, and then access that via e.source.id in the Event trigger.

    — answered November 2nd 2010 by Charlie Rosenbury
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.