douyi7055 2015-04-03 00:29
浏览 54

除非页面刷新,否则Jquery Mobile Web应用程序无法正常工作

I currently have a web application using jquery mobile that uses phploginscript. I have my index.html which re-irects to the login.php page (this is below)

<?php
if (version_compare(PHP_VERSION, '5.3.7', '<')) {
    exit('Sorry, this script does not run on a PHP version smaller than 5.3.7 !');
} else if (version_compare(PHP_VERSION, '5.5.0', '<')) {
    require_once('libraries/password_compatibility_library.php');
}
require_once('config/config.php');
require_once('translations/en.php');
require_once('libraries/PHPMailer.php');
require_once('classes/Login.php');
$login = new Login();
if ($login->isUserLoggedIn() == true) {
    include("views/logged_in.php");
} else {
    include("views/not_logged_in.php");
}

so when the user logs in it includes "logged_in.php" but the problem is that none of the javascript is running untill i refresh the page, as soon as i refresh the page everything is fine.

My first line of js in the page is :

$('#page').on('pageinit', function(){

thanks for your help i cant figure this one out..

  • 写回答

2条回答

  • douren2831 2015-04-03 00:58
    关注

    I found a quick but dirty fix for this by putting the script tag into the body in the page after the main like so :

    <body>
        <div data-role="page">
            <script>
                // Your javascript will go here
            </script>
            // And rest of your HTML content
        <div>
    </body>
    

    As this is a prototype design it will do for now.

    评论

报告相同问题?

悬赏问题

  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题