PDA

View Full Version : MVC and Component Listeners



Pandorian
3 Feb 2012, 2:50 AM
What I would like to do is take some action in my controller when the label part of a textfield is tapped.

I have looked at the sticky post above and created a component listener like this:



itemId :'testit',
xtype: 'selectfield',
name: 'KS',
label: 'Planning',
store: 'ScoreKey',
displayField: 'scoreKey',
valueField: 'scoreKeyId',

listeners: {
tap: {
fn: function() {
this.fireEvent('editoutcomefull');
// alert('fire');
},
element: 'label'
}
}




The alert will be displayed if the comment are removed. The problem I have is how do I fire an event that will be picked up by my controller?

I looked at this.getApplication().fireEvent() but this cause an error, and I cannot get my controller to re-act to this.fireEvent.

I have also tried adding a component listener to the controller directly, but couldn't get it to work.

Anybody any ideas on the best way to achieve this?

rhomb
3 Feb 2012, 5:18 AM
You could just use refs / controls to manage those events from the Controller
http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller

r (http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller)ho

Pandorian
3 Feb 2012, 5:35 AM
You could just use refs / controls to manage those events from the Controller
http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller

r (http://docs.sencha.com/touch/2-0/#!/api/Ext.app.Controller)ho




config: {
refs: {
KSTap: 'VisitOutcomes #testit'
},

control: {
KStap: {
tap: {
fn: function() {
alert('fire');
},
element: 'label'
},
},
}
},




Yes, I have tried that, but the event doesn't seem to fire - not sure if the syntax is OK.