1

我已经为此苦苦挣扎了好几天了。我正在尝试让选择菜单用作导航菜单。但是当我点击按钮时,什么也没有发生。感谢@Enrico,我认为我的 changePage 代码是正确的。我还发现需要在链接上关闭 Ajax。我试图禁用 Ajax 有点过火了。这是我的代码:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile.structure-1.2.0.min.css" />
<base href="http://kickfitness.com/" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script language="text/javascript">
/* VERY IMPORTANT this is before loading jquery.mobile JS */
$( document ).on( "mobileinit", function() {
    // Make your jQuery Mobile framework configuration changes here!
    $.mobile.allowCrossDomainPages = true;
            $.mobile.ajaxEnabled = false;
            });
 $(document).bind("mobileinit", function(){
        $.mobile.ajaxEnabled = false;
        });
</script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script>

<script language="text/javascript">
$(function() {
    $("#select-choice-1").change(function() {
        $.mobile.ajaxEnabled = false;
        $.mobile.changePage($(this).val());
    });        
});
</script>

这是我的菜单:

<div id="MobileWrapper" data-role="fieldcontain">
<select name="select-choice-1" id="select-choice-1" data-theme="a" data-form="ui-btn-up-a"data-native-menu="false" data-mini="false"><!-- data-native-menu="false" -->
<option data-placeholder="true">Navigation</option><!-- data=placeholder makes this not show up in the pop up-->
<option value="http://kickfitness.com/index.php">Home</option>
<option value="/services/index.php">Services</option>
<option value="trainers/index.php">Trainers</option>
<option value="/locations/index.php">Locations</option>
<option value="/calendar/index.php">Calendar</option>
<option value="/contactus/index.php">Contact Us</option>
</select>
</div><!--END MobileWrapper DIV-->

这是该页面的 URL。它是使用响应式 CSS 完成的,因此您可以通过将浏览器窗口设置得非常小来查看移动导航。 http://kickfitness.com/services/index2.php

任何帮助,将不胜感激。

4

1 回答 1

0

您不需要所有 $.mobile.ajaxEnabled 设置,只需调用 changePage 选项“reloadPage”等于 true:

$(function() {
    $("#select-choice-1").change(function() {
        $.mobile.changePage($(this).val(), { reloadPage: true } );
    });        
});
于 2012-12-18T04:29:00.653 回答