Worklight - jquery mobile 1.3.1 with jquery 1.10.2 - TypeError:$ .mobile is undefined

时间:2013-11-19 08:25:46

标签: jquery jquery-mobile ibm-mobilefirst

我的设置是Worklight 6.0.0.1,Jquery mobile 1.3.1和jquery 1.10.2。

当我以这种方式导入它们时:

    <!DOCTYPE HTML>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>KlapprJQ</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
        <link rel="shortcut icon" href="images/favicon.png">
        <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
        <link href="jqueryMobile/jquery.mobile-1.3.1.css" rel="stylesheet">
        <link rel="stylesheet" href="css/KlapprJQ.css">
        <script>window.$ = window.jQuery = WLJQ;</script>
        <script src="jqueryMobile/jquery.mobile-1.3.1.js"></script>
    </head>
    <body id="content">
    <div data-role="page">
        <!-- Empty page to initialize jQuery mobile -->
    </div>
        <script src="js/jquery-1.10.2.js"></script>
        <script src="js/initOptions.js"></script>
        <script src="js/KlapprJQ.js"></script>
        <script src="js/messages.js"></script>
        <script src="js/login.js"></script>
    </body>
    </html>

我收到以下错误:

    TypeError: $.mobile is undefined

当我尝试这样做时:

    $.mobile.loadPage("views/dialog.html", {});
$.mobile.changePage("views/login.html", {});

Worklight中使用jquery mobile的最佳做法是什么?

1 个答案:

答案 0 :(得分:3)

在jQuery库之后包含jQuery Mobile

    <script src="js/jquery-1.10.2.js"></script>
    <script src="jqueryMobile/jquery.mobile-1.3.1.js"></script>
    <script src="js/initOptions.js"></script>
    <script src="js/KlapprJQ.js"></script>
    <script src="js/messages.js"></script>
    <script src="js/login.js"></script>