Jquery $.mobile.changePage对Phonegap不起作用?

Jquery $.mobile.changePage对Phonegap不起作用?,jquery,mobile,jquery-mobile,cordova,Jquery,Mobile,Jquery Mobile,Cordova,我对$.mobile.changePage方法有一个问题,事实上,当我使用phonegap转换应用程序时,这个方法不起作用 这是我的page.html的代码。有解决办法吗 页面索引.html <!DOCTYPE html> <html> <head> <title>Prova </title> <link rel="stylesheet" href="css/jquery.mobile-1.0b1.css" /&

我对$.mobile.changePage方法有一个问题,事实上,当我使用phonegap转换应用程序时,这个方法不起作用

这是我的page.html的代码。有解决办法吗

页面索引.html

<!DOCTYPE html>
<html>
<head>
    <title>Prova </title>

    <link rel="stylesheet" href="css/jquery.mobile-1.0b1.css" />
    <script src="js/jquery-1.6.1.min.js"></script>
    <script src="js/jquery.mobile-1.0b1.js"></script>

    <script>
    $(document).ready(function() {

        $('#linkpersonale').click(function() {
            $.mobile.changePage("#personale", null, true, true);
        });

    });
    </script>


</head>
<body>

<div data-role="page" id="home">

<header data-role="header">
    <h1>Prova Page1</h1>
</header>

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


    <ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b" data-counttheme="d">
        <li>
            <a class="ui-link-inherit" id="linkpersonale">
                <h3 class="ui-li-heading">Personale</h3>
                <p class="ui-li-desc">...</p>
            </a>
        </li>
    </ul>

</div>


<footer data-role="footer" data-role="footer" data-id="footer-nav" data-position="fixed">
    <div data-role="navbar" id="navbar_home">
        <ul>
            <li><a href="#home" data-icon="home" data-iconpos="top" data-theme="a">Home</a></li>
        </ul>
    </div>
</footer>

</div>

</body>
</html>
网页personale.html

<!DOCTYPE html>
<html>
<head>
    <title>Prova </title>

</head>
<body>


<div data-role="page" id="personale">

<header data-role="header">
    <h1>Prova Pag2</h1>
</header>


<div data-role="content">

<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b" data-counttheme="d">
    <li>
        <a class="ui-link-inherit" href="#">
            <h3 class="ui-li-heading">Etc etc</h3>
            <p class="ui-li-desc">...</p>
        </a>
    </li>

</ul>

</div>

<footer data-role="footer" data-role="footer" data-id="footer-nav" data-position="fixed">
    <div data-role="navbar">
        <ul>
            <li><a href="#" data-icon="home" data-icon="home" data-iconpos="top" data-theme="a" data-transition="slide">Home</a></li>
        </ul>
    </div>
</footer>

</div>

</body>
</html>
有什么建议吗?PS:对不起我的英语,我是意大利人

试试看

$.mobile.changePage("personale.html", null, true, true); 
试一试


PhoneGap在这里是一条红鲱鱼。您应该将其作为普通的旧jQM代码进行测试,您将看到它在那里也不起作用。这是因为您正在引用一个HTML文件中不包含index.HTML的div

我会尝试调用personale.html上的changePage,而不是personale

从$.mobile.changePage上的文档:

to参数可以接受字符串,如文件url或本地元素的ID


PhoneGap在这里是一条红鲱鱼。您应该将其作为普通的旧jQM代码进行测试,您将看到它在那里也不起作用。这是因为您正在引用一个HTML文件中不包含index.HTML的div

我会尝试调用personale.html上的changePage,而不是personale

从$.mobile.changePage上的文档:

to参数可以接受字符串,如文件url或本地元素的ID


我认为这就是问题所在:

$.mobile.changePage("#personale", null, true, true);
因为personale.html是一个不同的文件,所以我认为您需要添加一个.html。相反,尝试

$.mobile.changePage("personale.html", null, true, true);
如果您想使用前面的代码,那么只需要将personale.html代码添加到pageindex.html页面。不管怎样,正确的页面都会显示出来,然后您可以像以前一样通过ID进行切换

PageIndex.html:

<div data-role="page" id="home">
<!-- CODE -->
</div>
<div data-role="page" id="personale">
<!-- CODE -->
</div>

注意:这将导致黑莓和HTC手机以及许多其他手机出现错误。他们将同时看到这两页。另一方面,任何mobile.changePage呼叫都无法与他们一起使用

我认为这就是问题所在:

$.mobile.changePage("#personale", null, true, true);
因为personale.html是一个不同的文件,所以我认为您需要添加一个.html。相反,尝试

$.mobile.changePage("personale.html", null, true, true);
如果您想使用前面的代码,那么只需要将personale.html代码添加到pageindex.html页面。不管怎样,正确的页面都会显示出来,然后您可以像以前一样通过ID进行切换

PageIndex.html:

<div data-role="page" id="home">
<!-- CODE -->
</div>
<div data-role="page" id="personale">
<!-- CODE -->
</div>

注意:这将导致黑莓和HTC手机以及许多其他手机出现错误。他们将同时看到这两页。另一方面,任何mobile.changePage调用都不会对他们起作用

正如在其他回答中所说,您可以将页面更改为“pagename.html”或其ID

您正在使用它的ID“personale”

在这种情况下,您应该使用JQ符号表示您正在使用变量=$:

$("#personale")
所以试试看

$.mobile.changePage($("#personale"), null, true, true);
还有一件事,你知道在移动html页面中,你可以在一个文件中放置更多的页面元素,对吗


这在切换页面时节省了一些加载时间。

如其他答案所述,您可以将页面更改为“pagename.html”或其ID

您正在使用它的ID“personale”

在这种情况下,您应该使用JQ符号表示您正在使用变量=$:

$("#personale")
所以试试看

$.mobile.changePage($("#personale"), null, true, true);
还有一件事,你知道在移动html页面中,你可以在一个文件中放置更多的页面元素,对吗


这可以在切换页面时节省一些加载时间。

您可以粘贴changePage功能吗?添加了jquery移动标签,希望可以将一些jquery移动人员带到这里来。您可以粘贴changePage功能吗?添加了jquery移动标签,希望可以将一些jquery移动人员带到这里来。