1

嗨,我在 IBM Worklight v 5.0.6 中进行 WP 7.5 应用程序开发时遇到问题。我使用来自ftp://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v506/wl_gs_all_samples.zip的 MultiPageApp 项目进行实验。

我有很多问题:

第一个问题

我在 worklight 中构建了 WP 7.5 环境,没有编辑代码。然后我在 MS Visual Studio 2012 中使用 Emulator 7.1 256MB 运行它。问题只是出现了来自 MultiPageApplication.html 的内容。

MultiPageApplication.html

<!DOCTYPE html>
<html>
    <head>
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta charset="utf-8">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" name="viewport">
        <title>MultiPageApplication</title>
        <link href="wlclient/css/wlclient.css" rel="stylesheet">
        <link href="images/favicon.png" rel="shortcut icon">
        <link href="images/apple-touch-icon.png" rel="apple-touch-icon">
        <link href="css/MultiPageApplication.css" rel="stylesheet">
        <script>

        // Define WL namespace.

        var WL = WL ? WL : {};



        /**

         * WLClient configuration variables.

         * Values are injected by the deployer that packs the gadget.

         */

        WL.StaticAppProps = {
   "APP_DISPLAY_NAME": "MultiPageApplication",
   "APP_SERVICES_URL": "http:\/\/169.254.17.188:8080\/apps\/services\/",
   "APP_VERSION": "1.0",
   "ENVIRONMENT": "windowsphone",
   "LOGIN_DISPLAY_TYPE": "embedded",
   "WORKLIGHT_ROOT_URL": "http:\/\/169.254.17.188:8080\/apps\/services\/api\/MultiPageApplication\/windowsphone\/"
};</script>
        <script src="wlclient/js/cordova.js"></script>
        <script src="common/js/wljq.js"></script>
        <script src="common/js/base.js"></script>
        <script src="wlclient/js/messages.js"></script>
        <script src="common/js/wlcommon.js"></script>
        <script src="wlclient/js/diagnosticDialog.js"></script>
        <script src="wlclient/js/deviceAuthentication.js"></script>
        <script src="wlclient/js/window.js"></script>
        <script src="wlclient/js/worklight.js"></script>
        <script src="wlclient/js/wlclient.js"></script>
        <script src="wlclient/js/wlfragments.js"></script>
        <script src="wlclient/js/encryptedcache.js"></script>
        <script src="wlclient/js/jsonstore/jsonstore.js"></script>
        <script src="wlclient/js/challengeHandlers/antiXSRFChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/authenticityChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/deviceAuthAutoProvisioningChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/deviceAuthNoProvisioningChallengeHandler.js"></script>
        <script src="wlclient/js/challengeHandlers/remoteDisableChallengeHandler.js"></script>
        <script src="wlclient/js/wlgap-wp7.js"></script><script>window.$ = window.jQuery = WLJQ;</script>

    </head>
    <body id="content" style="display: none">

        <div id="AppBody">
            <!-- This is static header, it will be shown always -->

            <div id="header">

                <h1>Multi page app</h1>

            </div>

            <!-- This is a placeholder for dynamic page content -->

            <div id="pagePort"></div>
        </div>

        <script src="js/initOptions.js"></script>
        <script src="js/MultiPageApplication.js"></script>
        <script src="js/messages.js"></script>

    </body>
</html>

MultiPageApplication.js

var pagesHistory = [];
var currentPage = {};

function wlCommonInit(){

    $("#pagePort").load("pages/MainPage.html", function(){
        currentPage.init();
    });
}

最后,我通过更改 jquery load API 的 URL(在 MS Visual Studio 2012 中手动)从

$("#pagePort").load("pages/MainPage.html",

$("#pagePort").load("default/pages/MainPage.html",

虽然代码可以运行,但另一个问题是

每次构建应用程序时都会重新生成 native/www 中的文件,因此对这些文件所做的任何更改都会丢失。

我应该怎么做才能正确生成 URL?

第二个问题

当我想通过按“加载 Page1”按钮将页面从 MainPage.html 导航到 Page1.html 时,

Page1.html 不会加载,因为 MultiPageApplication.js 中的方法“init”不起作用。我从 MS Visual Studio 2012 的输出日志中得到了这个错误:

Log:"Error in error callback: File564653615 = TypeError: Object doesn't support property or method 'init'"

我尝试使用 jQueryMobile jquery-1.9.1.min.js 和 jquery.mobile-1.3.2.min.js 更改 Worklight 中嵌入的 jQuery,但出现了同样的问题。

那么,我应该如何解决这个问题?是不是因为 Worklight 中嵌入的 jQuery 在 Visual Studio 中不起作用?

谢谢

4

1 回答 1

0

请尝试此处描述的解决方案:jQuery Mobile changePage() not working in Windows Phone

即:
打开jquery.mobile-1.3.2.js并重构以下内容:

-        var uri = url ? this.parseUrl( url ) : location,
-          hash = this.parseUrl( url || location.href ).hash;
+        var uri = this.parseUrl( url || location.href ),
+          hash = uri.hash;

和:

-        return uri.protocol + "//" + uri.host + uri.pathname + uri.search + hash;
+        return uri.protocol + uri.doubleSlash + uri.host + uri.pathname + uri.search + hash;

请注意,我只使用changePage方法检查了这一点,但希望这可以修复所有内容的文件位置,包括您所遇到的内容。

注意:请务必将应用程序恢复到其原始状态。

于 2013-08-11T06:05:34.193 回答