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?
app.profile.curState.fieldValue[rows.field(0)].addEventListener('change',function(e){
Ti.API.info('e.source: '+JSON.stringify(e.source)); //prints 'e.source: {}'
});
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
e.source.my_own_db_id
-
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?
-
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.