Php JQuery Mobile在刷卡后将页面()更改为同一页面
我试图在刷卡事件后使用JQuery Mobile的函数changePage()更改页面。加载的新页面与当前页面相同,只是参数不同(在我的例子中,它是一个日历,以年和月为参数) 我将其分解为一个简单的示例: test.php:Php JQuery Mobile在刷卡后将页面()更改为同一页面,php,javascript,jquery,html,jquery-mobile,Php,Javascript,Jquery,Html,Jquery Mobile,我试图在刷卡事件后使用JQuery Mobile的函数changePage()更改页面。加载的新页面与当前页面相同,只是参数不同(在我的例子中,它是一个日历,以年和月为参数) 我将其分解为一个简单的示例: test.php: <!DOCTYPE html> <html> <head> <title>Test</title> <meta http-equiv="content-type" content="text/htm
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).on("pageinit","#main",onPageInit);
function onPageInit(event)
{
$(document).on("swipeleft","#main",onSwipeLeft);
<?php
if ($_GET['id'] > 0)
{
?>
$(document).on("swiperight","#main",onSwipeRight);
<?php
}
?>
}
function onSwipeLeft(event)
{
//alert ("left");
//$.mobile.changePage("test.php?id=<?php echo $_GET['id'] + 1 ?>", { transition: "slide", allowSamePageTransition: true, reloadPage: true} );
$.mobile.changePage("test.php?id=<?php echo $_GET['id'] + 1 ?>", { transition: "none", allowSamePageTransition: true });
}
function onSwipeRight(event)
{
//alert ("right");
//$.mobile.changePage("test.php?id=<?php echo $_GET['id'] - 1 ?>", { transition: "slide", allowSamePageTransition: true, reloadPage: true} );
$.mobile.changePage("test.php?id=<?php echo $_GET['id'] - 1 ?>", { transition: "none", allowSamePageTransition: true });
}
</script>
</head>
<body>
<div data-role="page" id ="main" data-theme="a">
<div data-role="content" id ="content" data-theme="a">
<?php echo $_GET['id'] ?>
</div>
</div>
</body>
</html>
试验
$(document).on(“pageinit”,“main”,onPageInit);
函数onPageInit(事件)
{
$(文档).on(“swipeleft”,“#main”,onsweep left);
$(文档).on(“swiperight”,“#main”,onsweepRight);
}
函数左(事件)
{
//警惕(“左”);
//$.mobile.changePage(“test.php?id=,{transition:“slide”,allowSamePageTransition:true,reloadPage:true});
$.mobile.changePage(“test.php?id=,{transition:“none”,allowSamePageTransition:true});
}
功能右键(事件)
{
//警惕(“右”);
//$.mobile.changePage(“test.php?id=,{transition:“slide”,allowSamePageTransition:true,reloadPage:true});
$.mobile.changePage(“test.php?id=,{transition:“none”,allowSamePageTransition:true});
}
但这只适用于第一次刷卡。第二次刷卡后,我收到一个脚本错误:
TypeError:b.data(“移动页面”)未定义
奎尔达蒂:
泽尔:3
我尝试过不同的转换,但结果都一样
有什么想法吗?可能有用:$(文档)。一个(“pageshow”,“main”,onPageInit)代码>