我正在使用 JQM 框架做 phonegap 项目。
在这个项目中,我正在尝试使用向左滑动(打开)和向右滑动(关闭)来制作导航菜单。
这些代码在 Jquery 1.6.4 上运行良好。
但是当我将 Jquery 1.9.1 导入我的项目时,它不起作用。按钮单击有效,但滑动无效。
请不要告诉我继续使用 1.6.4,我需要帮助 :)
这是我的功能;
$(function(){
var menuStatus;
$("a.showMenu").click(function(){
if(menuStatus != true){
$(".ui-page-active").animate({
marginLeft: "265px",
}, 300, function(){menuStatus = true});
return false;
} else {
$(".ui-page-active").animate({
marginLeft: "0px",
}, 300, function(){menuStatus = false});
return false;
}
});
$('.pages').live("swipeleft", function(){
if (menuStatus){
$(".ui-page-active").animate({
marginLeft: "0px",
}, 300, function(){menuStatus = false});
}
});
$('.pages').live("swiperight", function(){
if (!menuStatus){
$(".ui-page-active").animate({
marginLeft: "265px",
}, 300, function(){menuStatus = true});
}
});
$("#menu li a").click(function(){
var p = $(this).parent();
if($(p).hasClass('active')){
$("#menu li").removeClass('active');
} else {
$("#menu li").removeClass('active');
$(p).addClass('active');
}
});
});
这是身体标签;
<body>
<div id="menu">
<h3>Menu</h3>
<ul data-role="listview" data-theme="d">
<li data-icon="delete"><a href="#" data-rel="close">Close Menu</a></li>
</ul>
</div>
<div data-role="page" class="pages" id="home">
<div data-role="header">
<a href="#"class="showMenu" data-icon="grid" data-iconpos="notext" data-shadow="false" data-iconshadow="false">Menu</a>
<h1>Loreee</h1>
</div><!-- /header -->
<div data-role="content">
<p><strong>Note: You can swipe right/left to show/close menu.</strong></p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<h1>footer</h1>
</div>
</div><!-- /page -->
</body>
等待你的答复。谢谢。