简体   繁体   中英

jQuery Load Local html file in Phonegap

I am creating multi page phone gap app

I have basic structure including css and scripts in index.html , i am trying to load content dynamically into container from other html pages.

When I load content of other dynamic page css is not reflecting on pages.

I have style sheets locally but still that style sheet is not applying on login.html after load

Style sheet cdn path for any one sing https://cdn.syncfusion.com/js/mobile/ej.mobile.all-latest.min.css

script cdn path https://cdn.syncfusion.com/js/mobile/ej.mobile.all-latest.min.js

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no" />
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>Login</title>
    <link href="css/font-awesome.min.css" rel="stylesheet" />
    <link href="css/ej.mobile.all.min.css" rel="stylesheet" />

    <link href="css/index.css" rel="stylesheet" />


</head>
<body>
    <div data-role="appview">
        <div id="header" data-role="ejmheader" data-ej-title="Leap Agent Portal"></div>

        <div id="content"></div>
    </div>
    <!-- Cordova reference, this is added to your app when it's built. -->
    <script src="cordova.js"></script>
    <script src="scripts/jquery-2.1.1.min.js"></script>
    <script src="scripts/jquery.validate.min.js"></script>
    <script src="scripts/jsrender.js"></script>
    <script src="scripts/ej.mobile.all.min.js"></script>
    <script src="scripts/platformOverrides.js"></script>
    <script>


var loadPage = function(url) {
    $.ajax({
        url: url,
    }).done(function (data) {
        $("#content").html(data);
    });
}

(function () {
    "use strict";

    document.addEventListener('deviceready', onDeviceReady.bind(this), false);

    function onDeviceReady() {
        loadPage("views/login.html");
    };
})();

    </script>

</body>
</html>

login.html

<form id="loginform" method="post">
    <h1>Enter Login Credentials</h1>
    <br />
    User Name
    <input type="text" required id="username" name="username"><br>
    <br />
    Password
    <input type="password" required id="password" name="password">
    <div align="center">
        <button type="submit" data-role="ejmbutton" data-ej-contenttype="textimage" data-ej-rendermode="auto"
                data-ej-imageclass="fa fa-key" id="btnlogin">
            Login
        </button>
    </div>
    <div id="message"></div>
</form>

If I write everything on single without load style sheets are rendering

在此处输入图片说明

No Style rendered if I loaded with jquery load

在此处输入图片说明

Have you try safari development inspector to check your DOM/CSS ? sometimes it helps ,-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM