我正在用Jquery Mobile編寫一個網上商店,我想使用選擇菜單瀏覽可用的類別。當用戶選擇一個類別時,我想導航到相同的頁面,但有一些參數添加到了URL中。這是我的選擇標記:Jquery Mobile Select不重置
<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:
function categoryClick() {
var mySelect = $("#productCatSelectMenu");
if (mySelect.val() != '') {
if (mySelect.val() == 0) {
$.mobile.changePage("shop.aspx", {reloadPage: true, transition:"slide"});
} else {
$.mobile.changePage("shop.aspx?c=" + $("#productCatSelectMenu").val() + "&n=" + $('#productCatSelectMenu :selected').text(), {reloadPage: true, transition:"slide"});
}
}
}
時候我已經航行一次,儘量選擇從選擇其他選項出現我的問題,我的JavaScript仍然retreives以前的值;選擇似乎沒有重置!但是,當我按F5並手動重新加載頁面時,菜單再次運行,直到我使用過一次。
任何人有任何想法,我怎麼能解決這個問題?正如你在javascript中看到的,「reloadPage:true」屬性不能解決問題。
是的,就像一個魅力。謝謝一堆! – karl 2011-12-20 07:10:48