Ext JS 中的单选框 Ext.form.Radio 添加点击事件

发布于 2024-09-07 15:48:07 字数 434 浏览 0 评论 0原文

我有一个简单的单选按钮:

new Ext.form.Radio({
                    id: 'ptype',
                    boxLabel:'Yes',
                    name: 'price_type',
                    value: 1
                })

但是我在添加单击事件时遇到问题。 我通常使用:

listeners: {
                click: function (a,e) {
                    //event
                }
}

作为配置参数,但在这种情况下它似乎不起作用。

任何建议表示赞赏,谢谢。

I have a simple radio button:

new Ext.form.Radio({
                    id: 'ptype',
                    boxLabel:'Yes',
                    name: 'price_type',
                    value: 1
                })

However Im having trouble adding a on click event ot it.
I usually use:

listeners: {
                click: function (a,e) {
                    //event
                }
}

As a config parameter, however it does not seem to work in this case.

Any advice appreciated, thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情深已缘浅 2024-09-14 15:48:07

单选按钮和复选框没有单击事件 - 我相信您想要 检查 事件。您的侦听器应如下所示:

listeners: {
    check: function (ctl, val) {
        // val is the new checked boolean value
    }
}

请注意 handler config 是一个方便的快捷方式(也可以在按钮上使用)。您可以这样做,而不是侦听器语法:

handler: function(ctl, val) {
    // etc
}

Radio and checkboxes do not have a click event -- I believe you want the check event instead. Your listener should look like:

listeners: {
    check: function (ctl, val) {
        // val is the new checked boolean value
    }
}

Note that the handler config is a handy shortcut for this (also available on buttons). Instead of the listeners syntax you could just do this:

handler: function(ctl, val) {
    // etc
}
苍白女子 2024-09-14 15:48:07

试试这个:

new Ext.form.Radio({
                    id: 'ptype',
                    boxLabel:'Yes',
                    name: 'price_type',
                    value: 1
                    onClick: function(e){
                     .....
                     .....
                    }
                })

Try this:

new Ext.form.Radio({
                    id: 'ptype',
                    boxLabel:'Yes',
                    name: 'price_type',
                    value: 1
                    onClick: function(e){
                     .....
                     .....
                    }
                })
_失温 2024-09-14 15:48:07

如果您使用的是 CheckBoxGroup,则应该执行类似的操作以确保您在正确的 Radio 上触发。

listeners: {
    check: function(checkbox, checked) {
        if(checked) {
                 // do whatever.
        }
    }
}

If you're using a CheckBoxGroup, you should do something like this to make sure you are firing on the correct Radio.

listeners: {
    check: function(checkbox, checked) {
        if(checked) {
                 // do whatever.
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文