简体   繁体   English

除非刷新页面,否则jQuery Mobile Web应用程序将无法运行

[英]Jquery Mobile web app not working unless page is refreshed

I currently have a web application using jquery mobile that uses phploginscript. 我目前有一个使用phploginscript的使用jquery mobile的Web应用程序。 I have my index.html which re-irects to the login.php page (this is below) 我有我的index.html,它重新显示到login.php页面(在下面)

<?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. 因此,当用户登录时,它包括“ logged_in.php”,但问题是直到刷新页面后,所有JavaScript都没有运行,只要刷新页面,一切都很好。

My first line of js in the page is : 我在页面中的第一行js是:

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

thanks for your help i cant figure this one out.. 感谢您的帮助,我无法弄清楚这一点。

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 : 我通过将script标签放在页面主体中的主要内容之后找到了一个快速但肮脏的解决方法,如下所示:

<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. 由于这是原型设计,因此现在可以使用。

在页面之间切换时,请使用rel =“ external”,因为它将触发整个页面的刷新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 除非页面刷新,否则 Grease/tampermonkey 脚本不起作用 - Grease/tampermonkey script not working unless page refreshed 除非刷新页面,否则在Rails中无法平滑滚动 - Smooth scrolling not working in Rails unless page is refreshed 从iframe写入会话后,除非刷新页面,否则jQuery,replaceWith()无法正常工作 - JQuery ,replaceWith() not working after writing to session from iframe, unless page is refreshed 除非应用程序是移动大小,否则jQuery动画和scrollTop无法正常工作 - jQuery animate and scrollTop not working unless app is mobile size 除非刷新页面,否则jQuery Ajax点击不起作用 - jQuery Ajax clicks doesn't work unless page is refreshed Rails 4 app ...在开发环境中javascript不会被触发,除非页面被刷新 - Rails 4 app… in development environment javascript not firing unless page is refreshed 除非刷新页面,否则AngularJS UI-Router无法正常工作 - AngularJS UI-Router not working unless page is refreshed 除非刷新页面,否则无法加载javascript - javascript will not load unless page is refreshed 网页浏览器刷新时,Angular应用无法正常工作 - Angular app not working when web browser refreshed 除非我刷新,否则jQuery mobile中的JavaScript无法正常工作 - JavaScript in jQuery mobile not working unless I refresh
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM