简体   繁体   English

带有JQuery的组中的ASP.Net RadioButtonList

[英]ASP.Net RadioButtonList in a Group with JQuery

I've got some radiobuttons in my webform, they are all part of the same group 我的网络表单中有一些单选按钮,它们都属于同一组

                <asp:RadioButton runat="server" ID="rbMonFriWkends" GroupName="HoursWkSelect" CssClass="ChbxToggler TogglesChbx-chbxToToggle VisibleToggle VisiToggles-divToToggle" />

I've got some JQuery handlers: 我有一些JQuery处理程序:

$(".ChbxToggler").click(function(){
    //Logic that pulls out any css classes that should be toggled and toggles 'em.
    return false;//This is part of the problem
});

$(".VisibleToggle").click(function(){
    //Logic that pulls out any css classes that should be toggled and toggles 'em.

    return false;//This is part of the problem
});

It all works but for one thing - the selection (ie the radiobutton which actually gets checked) never changes. 这一切都起作用,但有一件事情-选择(即实际上被选中的单选按钮)永远不会改变。

ie. 即。 if I click Radiobutton#1 everything toggles as it should but the selected radiobutton remains the one that was selected before the handler(s) run. 如果单击“单选按钮#1”,则所有内容都会按原样切换,但是所选单选按钮仍然是处理程序运行之前选择的单选按钮。 So the selection remains the same but the GUI changes as it should. 因此,选择保持不变,但GUI会发生变化。

Can someone help or at least explain what I'm doing wrong? 有人可以帮忙,或者至少可以解释我在做什么错吗? Happy to post more code if it'll help ... 乐于发布更多代码(如果有帮助的话)...

I think you answered that yourself with the comment next to return false; 我认为您在回答“ return false;回答了自己return false;

That appears to be cancelling your selection? 那似乎正在取消您的选择?

If you click a radio, your function is getting called, you are doing the work ie 如果您单击一个收音机,则会调用您的函数,您正在做的工作,即

Logic that pulls out any css classes that should be toggled and toggles 'em. 提取所有应切换的CSS类并切换'em'的逻辑。

but you are then cancelling the selection with return false; 但随后您将取消选择, return false;

You would only need to use return false if you click a link or post a form and you dont want to reload/navigate the page, but on a radio, this is not needed. 如果您单击链接或发布表单,并且不想重新加载/导航页面,则只需要使用return false ,但是在收音机上,则不需要这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM