Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1327] Event 'change' not firing in textfield if setting value

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionDuplicate
Resolution Date2014-05-19T05:34:44.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labels3.2.0GA, ios
ReporterLucas Alves
AssigneeRitu Agrawal
Created2014-05-14T19:57:15.000+0000
Updated2016-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.

Comments

  1. Ritu Agrawal 2014-05-15

    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();
       
       
  2. Lucas Alves 2014-05-16

    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.
  3. Ritu Agrawal 2014-05-19

    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.

JSON Source