저는 jQmobile을 처음 사용하고 jqMobile 사이트의 예제를 따라 왔습니다. 멀티 페이지 템플릿 형식을 사용하여 뒤로 버튼을 작동 시키려고합니다 (하드웨어 버튼). 그러나 두 번째 페이지에서 (하드웨어) 뒤로 버튼을 누르면 첫 페이지로 돌아가는 대신 응용 프로그램이 종료됩니다. 여기에 내가 사용하고있는 샘플 코드는 다음과 같습니다jQuery Mobile - 앱에서 뒤로 (하드웨어) 버튼이 작동하지 않습니다.
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
//This is your app's init method. Here's an example of how to use it
function init() {
document.addEventListener("deviceready", onDR, false);
}
function onDR(){
//document.addEventListener("backbutton", backKeyDown, true);
navigator.notification.alert("PhoneGap is working");
//boot your app...
}
function backKeyDown() {
// do something here if you wish
}
$(document).bind("mobileinit", function(){
$.mobile.touchOverflowEnabled = true;
$.mobile.defaultPageTransition = 'fade';
});
</script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
</head>
<!-- Start of first page -->
<div data-role="page" id="foo">
<div data-role="header">
<h1>Foo</h1>
</div><!-- /header -->
<div data-role="content">
<p>I'm first in the source order so I'm shown as the page.</p>
<p>View internal page called <a href="#bar">bar</a></p>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
<!-- Start of second page -->
<div data-role="page" id="bar">
<div data-role="header">
<h1>Bar</h1>
</div><!-- /header -->
<div data-role="content">
<p>I'm the second in the source order so I'm hidden when the page loads. I'm just shown if a link that references my ID is beeing clicked.</p>
<p><a href="#foo">Back to foo</a></p>
</div><!-- /content -->
<div data-role="footer">
<h4>Page Footer</h4>
</div><!-- /footer -->
</div><!-- /page -->
</body>
감사, 사전에 모든 답변에 대해.
? 당신은 마크 업을 게시했습니다 ... – MilkyWayJoe
어떤 장치를 사용하고 있습니까 ? –
은하 SII뿐만 아니라 에뮬레이터에서 테스트되었습니다. 나는 OP에 javascript를 추가했다. – azsl1326