Event change doesn't fire on dynamically populated Picker - Titanium SDK

You must Login before you can answer or comment on any questions.

I'm trying to create a custom Picker whose data is from a remote JSON. The problem is that it doesn't fire the 'change' event on the picker at the first time when I select a row from the picker, I have to close the picker and select a row from the picker again and then the event change works.

var clubs_data = [];
//custom object to handle the httpClient
new K().scoutmobile.Tools.getData(new K().scoutmobile.URL_BASE, {Accion:new K().scoutmobile.CLUBS}, function(_response){
    if(response.status.codigo === "RESULT"){
        clubs_data.push(Ti.UI.createPickerRow({title:'select a club'}));
        for(_j in _response.data){
            clubs_data.push(Ti.UI.createPickerRow({color:'#fff',title: _response.data[_j].Propiedades.club_nombre.Valor, id:_response.data[_j].Propiedades.club_id.Valor}));
 
        inputClubs.add(clubs_data); //where inputClubs is created previously
 
    }else{                              
        new K().scoutmobile.Tools.createDialog('invalid_user_alert_dialog_title','invalid_user_alert_dialog_message');
    }
});
 
//event listener
inputClubs.addEventListener('change', function(e){
        Ti.API.info(e.row.id);
    });
 
win.add(inputClubs);
In the Titanium Studio Console I get this:
[WARN][InputManagerService(   60)] Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43f8dbb8
Any ideas what it is happening?

— asked 8 months ago by Felix Guerrero
1 Comment
  • Note: using a picker generated from static data (array populated with Ti.Ui. createPickerRow) the event "change" works well.

    — commented 8 months ago by Felix Guerrero

1 Answer

Accepted Answer

Have you tried firing the event manually when the app starts?

Put this just before the win.add line:

inputClubs.fireEvent('change');

— answered 7 months ago by Clifton Labrum
answer permalink
2 Comments
  • I had to create a custom event variable as well because I'm detecting the event with a listener. Thanks.

    — commented 7 months ago by Felix Guerrero

  • Felix, How do you mean 'create a custom event variable' on your last reply?
    thx

    — commented 3 months ago by Brian Burgess

Your Answer

Think you can help? Login to answer this question!