Javascript jquerymobile-loadPage问题

Javascript jquerymobile-loadPage问题,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,我在获取jQuery mobile的加载页面以将下一页加载到“content”div时遇到问题 我已经将我的页面缩减到基本内容,下面是代码 index.html: <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>JQu

我在获取jQuery mobile的加载页面以将下一页加载到“
content
div
时遇到问题

我已经将我的页面缩减到基本内容,下面是代码

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 -->

我不认为您可以将一个页面加载到另一个页面中,但您可以尝试以下方法:

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

这将从容器内的第2页加载内容(
),然后它将触发原始页面上的创建事件,以在某种程度上增强加载的内容,但它不会将内容加载到我的div中,它会将整个页面更改为nextPage.html。@user2158259是否替换容器的内容或附加它?替换容器的内容。@user2158259我认为嵌套页面不能同时可见