Titanium Community Questions & Answer Archive

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

Determine object that triggered callback?

I have several text fields that I want to callback to a common function to process them on change. I can't find how to determine WHICH of these text fields triggered the callback, so that I can update the database with the value.

My code looks something like this:

function updateTextField( e ) {
  valueToUpdate = e.value;
  // But which textField did it come from?
}

var myTF = makeTextField({ ... });
myTF.addEventListener( 'change', updateTextField );

Is there an attribute that I'm missing that will tell me this, or should I use an anonymous function for each of the multitude of text fields?

— asked July 15th 2010 by shane doucette
  • callback
  • textfield
0 Comments

2 Answers

  • e.source
    
    — answered July 15th 2010 by Dan Tamas
    permalink
    1 Comment
    • Hey Tamas,

      That gives the entire object, but according to the TextField docs, there's no property that I can set or read that would include the name. Or did I miss something?

      — commented July 15th 2010 by shane doucette
  • what name?
    can you explain more?
    you can set

    e.source.value
    
    — answered July 15th 2010 by Dan Tamas
    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.