PDA

View Full Version : Event not firing properly



Xenology
25 Jan 2012, 11:30 AM
I'm trying to fire a custom event in sencha touch, and it seems to get added to the events that can be fired, and it appears to fire, but my listener does not seem to respond to the event.


the event is instantinated here, where this is the form body:



Ext.apply(this, {
scroll: 'vertical',
dockedItems: [ titlebar, buttonbar ],
items: [ fields ],
listeners: {
beforeactivate: function() {
var saveButton = this.down('#userFormSaveButton');
saveButton.setText('Submit');
this.addEvents('cityUpdate');
console.log('event added');

},
deactivate: function() {
this.resetForm();
}
}
});


The event is then fired here:



if (result.data != 'false' && result.data.state) {
Ext.getCmp("usersForm").fireEvent('cityUpdate', result.data.towns);
console.log('event fired');
alert('Your town is ' + result.data.towns + ' ' + result.data.state.replace( /\+/g , ' ' ));

}


Then the listener is applied to a field in the form here:



{
xtype: 'textfield',
name: 'city',
label: 'City*',
placeHolder: 'New York',
useClearIcon: true,
id:'city',
listeners: {
cityUpdate: function(city) {
console.log('event reponse' , this.fieldEl.dom , city);
}
}
},


Can someone explain to me why I am not able to see the event response call in the console? I see event added and event fired, but I never seem to get the event to actually run the event responded console statement. I receive no errors in the console, so I'm at somewhat of a loss as to what is happening here?