javascript - How to listen whether a radiobutton is checked with ExtJS? - Stack Overflow

{xtype : 'radiogroup',items : [{boxLabel : 'jjj',name : 'tyutrfytr',input

{xtype : 'radiogroup',
            items : [{
                boxLabel : 'jjj',
                name : 'tyutrfytr',
                inputValue : 1,
                checked : true
            }, {
                boxLabel : 'kkk',
                name : 'dfdsfdsddd',
                inputValue : 2,
                listeners: {
                      check : function(cb, rec, ind) {
                            alert('hhhh');
                       }
                 }
            }]
}

The code above gives alert no matter whether I press first option or second option. Shouldn't it alert only when the second option is checked?

{xtype : 'radiogroup',
            items : [{
                boxLabel : 'jjj',
                name : 'tyutrfytr',
                inputValue : 1,
                checked : true
            }, {
                boxLabel : 'kkk',
                name : 'dfdsfdsddd',
                inputValue : 2,
                listeners: {
                      check : function(cb, rec, ind) {
                            alert('hhhh');
                       }
                 }
            }]
}

The code above gives alert no matter whether I press first option or second option. Shouldn't it alert only when the second option is checked?

Share Improve this question asked Sep 8, 2011 at 12:33 ilhanilhan 9,01335 gold badges127 silver badges214 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

the event fires whenever the radio gets checked or unchecked..

check : ( Ext.form.Checkbox this, Boolean checked ) Fires when the checkbox is checked or unchecked. Listeners will be called with the following arguments: this : Ext.form.Checkbox This checkbox checked : Boolean The new checked value

  listeners: {
                          check : function(cb, value) {
                                if (value) alert('check');
                                   else alert('uncheck');
                           }
                     }

This code works well in version 4.2:

xtype: 'radiogroup',
id: 'RadioGroupId',
fieldLabel: 'The Radio Group',
items: [{
    xtype: 'radiofield',
    boxLabel: 'The first radio',
    id: 'FirstRadioId',
    name: 'radios',
    inputValue: 1,
    listeners: {
        change: function (cb, newValue, oldValue) {
            if (newValue) {
               // First radio button has been selected
            } else {
               // Second radio button has been selected
            }
        }
    }
}, {
    xtype: 'radiofield',
    boxLabel: 'The second radio',
    id: 'SecondRadioId',
    name: 'radios',
    inputValue: 2,
    checked: true
}]

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745337176a4623160.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信