PDA

View Full Version : adding listeners to x template



pkvenu
9 Nov 2011, 10:34 AM
Hi guys,

I am having some problem with adding listeners to x template and get the value of the selected radio control when a select button is clicked . can some one help me with it.

I have a template which gets its values JSON. The template basically adds a list of radio buttons to the panel. as shown below


var popupResultTemplate = new Ext.XTemplate(
'<tpl for=".">',
'<div>',
'<input id={Representation} type="radio" name="group1" value="{Representation}" /> {Representation} <br />',
'<div>',
'</tpl>'
);

The result list is bound to a popup window


var resultList = new Ext.Panel({
scroll: 'vertical',
tpl: popupResultTemplate
});







var popup = new Ext.Panel({
floating: true,
centered: true,
modal: true,
width: 300,
height: 400,
dockedItems: [
{
xtype: 'toolbar',
title: 'PopUp',
items: [{
xtype: 'spacer'
}, {
text: 'Close',
handler: function () {
popup.hide();
}
}]
},
{
xtype: 'toolbar',
items: [{ xtype: 'spacer' },
{ xtype:'button',

cls: 'citySearch',
text: 'Select',
handler: function () {
Ext.dispatch({
controller: parking.controllers.controller,
action: 'showMapBasedOnInputLocation',

});
}
}]
}
],
items: [resultList]
});

Thanks,
Pawan

mitchellsimoens
10 Nov 2011, 5:20 AM
Not tested at all but something along the lines of:


panel.mon(panel.body, {
delegate: 'input',
click: someFn
});

pkvenu
10 Nov 2011, 8:24 AM
I could'nt get the method to work as per your suggestion. I added something like this for me to get it working


var resultList = new Ext.Panel({
scroll: 'vertical',
tpl: popupResultTemplate,
listeners: {
el: {
tap: function (ctl) {
alert("Checked " + ctl.target.value);
},
delegate: "input"
}
}
});

Hope it helps some one.

Thanks,
Pawan