jQuery Mobile - 페이지 이동 API
웹앱을 개발하다보면 JavaScript 에서 페이지 이동을 해야할 경우도 발생한다. 이를 위해 jQuery Mobile 은 $.mobile.changePage() 메소드를 제공한다.
$.mobile.changePage("#page");
$.mobile.changePage("page.html");
changePage()메소드의 매개값은 이동할 페이지 경로이다. 두 번째 매개값을 지정할 수 있는데, 두번째 매개값은 구성 객체({})로 작성해서 여러가지 구성 옵션을 설정한다.
페이지 트랜지션을 지정하고 싶다면 다음과 같이 호출한다.
$.mobile.changePage("page.html",{ transition: "slideup"});
$.mobile.changePage("page.html",{ transition: "slideup", reverse: true})
MainPage.html
<!DOCTYPE html>
<html>
<head>
<meta charset="euc-kr" />
<mata name="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"/>
<title> jQuery Mobile</title>
<link rel="shortcut icon" href="./image/icon.png">
<link rel="apple-touch-icon" href="./image/icon.png">
<link href="./framework/jquery.mobile-1.0.css" rel="stylesheet" type="text/css" />
<script src="./framework/jquery-1.6.4.js"></script>
<script src="./framework/jquery.mobile-1.0.js"></script>
<script type="text/javascript">
function changePage(){
$.mobile.change("secondpage.html", {transition:"slideup",reverse:true});
}
</script>
</head>
<html>
<head>
<meta charset="euc-kr" />
<mata name="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"/>
<title> jQuery Mobile</title>
<link rel="shortcut icon" href="./image/icon.png">
<link rel="apple-touch-icon" href="./image/icon.png">
<link href="./framework/jquery.mobile-1.0.css" rel="stylesheet" type="text/css" />
<script src="./framework/jquery-1.6.4.js"></script>
<script src="./framework/jquery.mobile-1.0.js"></script>
<script type="text/javascript">
function changePage(){
$.mobile.change("secondpage.html", {transition:"slideup",reverse:true});
}
</script>
</head>
<body>
<div id="home" data-role="page">
<div data-role="header">
<h1>changePage()</h1>
</div>
<div data-role="content">
<a href="javascript:changePage()" data-role="button"> Second Page</a>
</div>
</div>
</body>
<div id="home" data-role="page">
<div data-role="header">
<h1>changePage()</h1>
</div>
<div data-role="content">
<a href="javascript:changePage()" data-role="button"> Second Page</a>
</div>
</div>
</body>
</html>
SecondPage.html
<!DOCTYPE html>
<html>
<head>
<title>jQuery Mobile</title>
</head>
<html>
<head>
<title>jQuery Mobile</title>
</head>
<body>
<div id="secondPage" data-role="page" data-add-back-btn="true">
<div data-role="header">
<h1>Second Page</h1>
</div>
</div>
<div id="secondPage" data-role="page" data-add-back-btn="true">
<div data-role="header">
<h1>Second Page</h1>
</div>
</div>
</body>
</html>
'' 카테고리의 다른 글
jQuery Mobile - 페이지 이벤트( 로드, 초기화, 제거, 트랜지션) (0) | 2012.07.23 |
---|---|
jQuery Mobile - moblieinit 이벤트 (0) | 2012.07.22 |
jQuery Mobile - 페이지 이동 API (1) | 2012.07.21 |
jQuery Mobile - 페이지 트랜지션 (2) | 2012.07.20 |
jQuery Mobile - 다른 웹앱 실행 , 데이터 링크 (0) | 2012.07.19 |
jQuery Mobile UI - 페이지 (0) | 2012.07.18 |
댓글을 달아 주세요
굳
이것 때문에 골치였는데 감사합니다.