Jquery mobile Jquery Mobile Select不重置

Jquery mobile Jquery Mobile Select不重置,jquery-mobile,Jquery Mobile,我正在用jquerymobile编写一个网上商店,我想使用一个选择菜单来浏览可用的类别。当用户选择一个类别时,我想导航到同一个页面,但在url中添加了几个参数。这是我的选择标记: <asp:Repeater id="productCatSelect" runat="server"> <HeaderTemplate> <select id="productCatSelectMenu"

我正在用jquerymobile编写一个网上商店,我想使用一个选择菜单来浏览可用的类别。当用户选择一个类别时,我想导航到同一个页面,但在url中添加了几个参数。这是我的选择标记:

  <asp:Repeater id="productCatSelect" runat="server">
                <HeaderTemplate>
                        <select id="productCatSelectMenu" data-native-menu="false" onchange="categoryClick();" class="button" data-theme="a">
                        <option data-placeholder="true">All Categories</option>
                </HeaderTemplate>
                <ItemTemplate>
                    <option value="<%# Eval("NodeID") %>" ><%# Eval("Description")%></option>
                </ItemTemplate>
                <FooterTemplate>
                    </select>
                </FooterTemplate>
</asp:Repeater>
当我导航一次并尝试从选择中选择另一个选项时,我的问题就出现了,我的javascript仍然检索以前的值;选择似乎没有重置!但是,当我按F5并手动重新加载页面时,菜单会再次工作,当然,直到我使用过一次

有人知道我该怎么解决这个问题吗?正如您在javascript中看到的,reloadPage:true属性无法解决问题。

您是否尝试过$'productCatSelectMenu'。selectmenu'refresh'


您可以检查有关刷新方法的信息

您需要自己重置此方法,可以尝试:

$('select#productCatSelectMenu option').attr('selected', false);

前几天我也有类似的问题


如果您使用的是jQuery Mobile的自定义选择字段,请尝试

$("#select_id").selectmenu('refresh', true) 

这将成功重置jQuery mobile提供的选择选项。

我不知道为什么jQuery mobile select会以这种方式工作。除了这里提到的以外,以上这些对我都不起作用。我正在使用当前版本 jquery-1.10.2.min.js jquery.mobile-1.4.2.min.js


这将刷新jQM控件,但不会刷新SelectedIndex如果它可以帮助其他人,我也使用jQuery mobile,在寻找了很长时间如何重置selects之后,我根据Timothy的回答找到了这个解决方案:$form_id select.selectmenu'refresh',true;根据页面的加载状态,您可能仍然需要删除attr$选择_id选项。删除'selected';除非添加$'selectproductCatSelectMenu'。selectmenurefresh;,否则它不起作用,喜欢@user3679385的答案,
$('select#productCatSelectMenu option').removeAttr('selected');
$('select#productCatSelectMenu').children('option').removeAttr('selected').filter(':nth-child(1)').attr('selected', true);
$('select#productCatSelectMenu').attr('selectedIndex', -1);
$("#select_id").selectmenu('refresh', true) 
var myselect = $("select#useOfColor");
myselect[0].selectedIndex = 0;
myselect.selectmenu("refresh");