[AC-1327] Event 'change' not firing in textfield if setting value
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Resolved |
| Resolution | Duplicate |
| Resolution Date | 2014-05-19T05:34:44.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | 3.2.0GA, ios |
| Reporter | Lucas Alves |
| Assignee | Ritu Agrawal |
| Created | 2014-05-14T19:57:15.000+0000 |
| Updated | 2016-03-08T07:37:44.000+0000 |
Description
If you manually set the value of a text field, the 'change' event is not fired.
Testcase:
var txt = Ti.UI.createTextField({
enabled: true,
hintText: 'change me'
});
txt.addEventListener('change', function(e) {
Ti.API.info('text changed');
});
var btn = Ti.UI.createButton({
bottom: 0,
title: 'Change Text'
});
btn.addEventListener('click', function(e) {
txt.value = 'Yay, text changed!';
});
$.win.add(btn);
$.win.add(txt);
When I change the text by focusing the textfield and typing the event is correctly fired, but if I click the button the event is never fired.
Thanks.
I ran your code and it was working as expected. I clicked the button "Change Text" and the event got fired. Test case
var win=Ti.UI.createWindow({ backgroundColor:'white' }); var txt = Ti.UI.createTextField({ enabled: true, hintText: 'change me' }); txt.addEventListener('change', function(e) { Ti.API.info('text changed'); }); var btn = Ti.UI.createButton({ bottom: 0, title: 'Change Text' }); btn.addEventListener('click', function(e) { txt.value = 'Yay, text changed!'; }); win.add(btn); win.add(txt); win.open();Did you run it on iOS 7.1, 3.2.2GA? I just re-tested it on the iOS simulator and it didnt work as expected, event is NOT fired for me. The only different thing that I have from you is that mine is an alloy project, so my window is defined in a .xml file. Could this be an alloy problem? Thanks.
I can reproduce this issue but it appears to be an iOS behavior as we can reproduce this behavior with a native iOS application. Please see ticket TIMOB-16318 for more information. Resolving this ticket as a duplicate of TIMOB-16318.