[英]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.