PDA

View Full Version : TypeError: 'undefined' is not an object (evaluating 'firingFn.apply')



msweltzdk
30 Jan 2012, 2:43 AM
I am using Sencha Touch 2.0 PR4

I am trying to add a listener to a button event.

If I add the code like this, everything works fine:




control: {
btnAddParticipant: {
tap: function () {
var participantsStore = Ext.getStore('Participants'),

params = iBygning.app.getController('MainNavigation').getPersist();

Ext.apply(params, participantsStore.getProxy().getParams());

participantsStore.load({
params: params
});

}


}
},


But if I change the code to what looks and feels more right like the following, I get the error written in the subject:




control: {
btnAddParticipant: {

tap: 'loadParticipantsOverlay'


}
},

loadParticipantsOverlay: function () {
var participantsStore = Ext.getStore('Participants'),

params = iBygning.app.getController('MainNavigation').getPersist();


Ext.apply(params, participantsStore.getProxy().getParams());


participantsStore.load({

params: params

});
}

Can someone guide me to what the issue I am having could be?

mitchellsimoens
30 Jan 2012, 9:14 AM
Saying the event string you pass isn't on the class. This works for me:


Ext.define('MyContainer', {
extend : 'Ext.Container',
xtype : 'mycnt',

config : {
items : [
{
xtype : 'button',
text : 'Test'
}
],

control : {
'button' : {
tap : 'loadParticipantsOverlay'
}
}
},

loadParticipantsOverlay : function(btn) {
console.log(btn);
}
});

msweltzdk
30 Jan 2012, 11:49 PM
First of, thanks for the reply.

The only problem I have with your solution is that I don't want any logic in my views. I forgot to mention that my previous example is in a controller.

btnAddParticipant is being defined via a ref, and it picks the tap event up nicely, just doesn't fire the event properly. (If I change the selector for the ref, the tap doesn't do anything)

paul_todd
31 Jan 2012, 1:54 AM
Did you make sure your loadParticipantsOverlay method is outside of the config block?

msweltzdk
31 Jan 2012, 4:45 AM
Thank you, paul_todd. For some reaons I had been staring blindly at such a silly mistake. Fixed. :)