当页面刷新时,jquery buttonset恢复为单选按钮列表

时间:2013-01-03 20:58:46

标签: javascript jquery jquery-ui

基本上我有以下代码,每次刷新页面时,按钮组都会恢复为单选按钮。我做错了吗?

<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
    $( ".filter_type" ).buttonset();
});
</script>

<asp:RadioButtonList ID="rbtnTimeRange" class="filter_type" name="filter_type"   RepeatDirection="Horizontal" 
                AutoPostBack="true" runat="server"  OnSelectedIndexChanged="TimeRange" >
            <asp:ListItem Value="1" Selected="True">Today</asp:ListItem>
            <asp:ListItem Value="5">MTD</asp:ListItem>
        </asp:RadioButtonList>

1 个答案:

答案 0 :(得分:0)

按如下方式修改您的asp代码(注意标记style="display:none"

<asp:RadioButtonList ID="rbtnTimeRange" class="filter_type" Style="display:none" name="filter_type"   RepeatDirection="Horizontal" AutoPostBack="true" runat="server"  OnSelectedIndexChanged="TimeRange" >
    <asp:ListItem Value="1" Selected="True">Today</asp:ListItem>
    <asp:ListItem Value="5">MTD</asp:ListItem>
</asp:RadioButtonList>

然后在jQuery中使用$( ".filter_type" ).show();,如下所示

<script>
$(function() {
    $( ".filter_type" ).buttonset();
    $( ".filter_type" ).show();
});
</script>