douyan2970 2013-09-06 12:18
浏览 42
已采纳

jquery mobile不会激活pageinit或准备好

i have 3 php pages, 1 index page and 2 other subpages which have links (sales and products) in the index page. when i click on sales, it is suppode to load sales data on pageint or document ready as am using below to debug.

$('[data-role="page"]').live('pageshow', function () { <-- error line
    console.log("pageshow");
});

$(document).on('pageinit', function(){ 
console.log("pageinit");
});
$(document).ready(function(){

    console.log("docready");
})

none of the code fire when i click the link on in index page, but when the page is loaded and i refresh, i get a javascript error indicated by the error line

Object [object Object] has no method 'live' 

i am using

jquery.1.9.1.min.js
jquery.mobile.1.3.2.min.js

the html of the index page is

<div data-role="page" data-ajax="false" id="home">
    <?php include_once("header.php");?>
    <div data-role="content" data-theme="">    
        <ul data-role="listview" data-divider-theme="b" data-inset="true">
            <li data-role="list-divider" role="heading">Menu</li>
            <li data-transition="flip">
                <a href="outgoing.php" data-transition="slide" data-ajax="true">sales </a>
            </li>
            <li data-transition="flip">
               <a href="settings.php" data-transition="slide" data-ajax="true">products</a>
            </li>
            <li>
                <a href="../logout.php">Logout</a>
            </li>
    </ul><div data-role="navbar" data-iconpos="">
        </div>
    </div>
    <div data-role="footer" data-theme="b">
    <?php include_once("../footer.php");?></h4>
  </div>
</div>

what am i doing wrong?

Edit

I updated my code as to $('[data-role="page"]').on('pageshow', function () {, but non of the functions fire except i refresh the page manually after it has been full loaded

  • 写回答

2条回答 默认 最新

  • dongwei3712 2013-09-11 01:02
    关注

    i solved the problem by setting data-ajax=false in the link that loaded the page thats not firing document readey and the rest

    <a href="page.php" data-ajax="false">link</a>
    

    thanks

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog