2013-08-26 5 views
2

jQuery-mobile로드 페이지를 가져 오는 중에 "content"div에로드하는 데 문제가 있습니다.jquery mobile - loadPage 문제

나는 내 페이지를 기본으로 자르고 여기에 코드가있다. 나는 당신이 다른 페이지 내에서 페이지를로드 할 수 있다고 생각하지 않습니다

index.html:

<html lang="en"> 
<head> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>JQuery Mobile Load Page Test</title> 
    <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> 
</head> 
<body> 

<div data-role="page"> 

    <div id="containerTest" data-role="content"> 

     <input type="button" id="nextPage" data-inline="true" value="Load Second Page"/> 

    </div> <!-- /content --> 

</div> <!-- /page --> 

<script> 

    $("#nextPage").on("click", function() 
    { 
     $.mobile.loadPage("nextPage.html", 
     { 
      pageContainer: $('#containerTest') 
     }); 
    }); 

</script> 

</body> 
</html> 

<div data-role="page"> 

    <p>this is the next page</p> 

</div> <!-- /page --> 

답변

1

nextPage.html, 당신은하지만 이런 일을 시도 할 수 :

$(document).on('pageinit', function(){ 
    $("#nextPage").on("click", function(){ 
     $('#containerTest').load('nextPage.html [data-role="content"]',function(){ 
      $('.ui-page-active').trigger('create'); 
     }); 
    }); 
}); 

2 페이지의 내용 (<div data-role="content">)을 컨테이너 내부에로드하면 원래 페이지에서 create 이벤트가 트리거되어로드 된 내용이 향상됩니다.

+0

다소 있지만 내용이 내 div에로드되지 않습니다 < div id = "containerTest"data-role = "content">, 전체 페이지를 nextPage.html로 변경합니다. – user2158259

+0

@ user2158259 컨테이너 내용을 바꾸거나 추가 하시겠습니까? –

+0

컨테이너 내용을 바꿉니다. – user2158259