1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default adding listeners to x template

    adding listeners to x template


    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

    Code:
    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

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




    Code:
    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

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,227
    Vote Rating
    859
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Not tested at all but something along the lines of:

    Code:
    panel.mon(panel.body, {
        delegate: 'input',
        click: someFn
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Posts
    40
    Vote Rating
    0
    pkvenu is on a distinguished road

      0  

    Default


    I could'nt get the method to work as per your suggestion. I added something like this for me to get it working

    Code:
    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

Thread Participants: 1

Tags for this Thread