开发者

How to Add Listeners to RadioButtons in EXTJS4

开发者 https://www.devze.com 2023-04-09 05:43 出处:网络
I\'m very new to ExtJs and I wanted to display an alert box on clicking one of the radio buttons, but it does not seem to work. Could anyone guide me through this step? The listener does not seem to w

I'm very new to ExtJs and I wanted to display an alert box on clicking one of the radio buttons, but it does not seem to work. Could anyone guide me through this step? The listener does not seem to work.

{
    xtype: 'radiogroup',
    fieldLabel: 'Does Nodes hav开发者_Go百科e DHCP IP Scheme?',
    id:'dhcpRadio',
    columns: [50, 50],
    // Arrange radio buttons into two columns, distributed vertically
    columns: 2,
    vertical: true,
    items: [{
    boxLabel: 'Yes',
        name: 'rb', 
        inputValue: 'yes',
        listeners: {
            check: function(rb,value){
                if(value=='yes') 
                    alert('yes');
                else alert('no');
            }
        }
    },{
        boxLabel: 'No',
        name: 'rb',
        inputValue: 'no',
        checked: true
    }]
}


Like Gregory just said, Radio does not have a click event. You could try the change event instead:

listeners: {
    change : function(rb, newValue, oldValue, options) {
        if( newValue === 'yes') {
            alert('Yes')
        } else {
            alert('No')
        }
    }
}

See the API documentation for details.


Radio do not have a click event

Instead of the listeners try this:

handler: function(ctl, val) {
  alert("ddd");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消