如何在 IBM Worklight 中重定向到同一页面但不同的 div/view?

How to redirect to same page but to a different div/view in IBM Worklight?

最初仅通过用户名而不是密码进行测试。 成功登录后,它会发出登录成功警报,但无法重定向到同一 html 页面 (YummyjQueryMobile145.html).

上的特定 div 或视图(来自移动导航 IBM Worklight)

测试代码如下:

//#login > login button id
//#home > redirected div/view id

$(function(){
$("#login").click(function(){
                $("#home").load("YummyjQueryMobile145.html", function(){
                    alert("loaded!");
                });
            });
});

JS文件

function Login()
    {
        //alert("Login");
        var invocationLogin={
                adapter:"SQL_ADAPTER_Yummy",
                procedure:"procedureLogin",
                parameters:[]
               };

    var optionsLogin={
            onSuccess:succLogin,
            onFailure:failLogin
            };
    WL.Client.invokeProcedure(invocationLogin,optionsLogin);
    }

    function succLogin(result)
    {
        //alert("succLogin");
        var LUname=$("#LUname").val();
        var LPass=$("#LPass").val();
        var flag=0;
        var n;

        var i,
        resultSet = result.invocationResult.resultSet;
        //alert(result.invocationResult.resultSet);
        namesArray = [];

        for (i = 0; i < resultSet.length; i++)
        {
        namesArray[i] = resultSet[i].NAME;
        }

        //alert (JSON.stringify(namesArray));

        for (i = 0; i < resultSet.length; i++)
        {
            n = LUname.localeCompare(namesArray[i]);
            if(n==0)
            flag=1;
        }

        if(flag==1)
            {
            alert("Login Successful");
            //Here the Redirect code/same html page to a particular div or view
           //clicking login button if success then redirect to home div/view

            }
        else
            alert("Try Again!!!");

    }

    function failLogin(result)
    {
         alert(result+"try again Login");
    }

HTML

....
<div class="bg" id="LogIn" data-role="page" data-add-back-btn="true"
data-back-btn-text="Home" data-theme="b">
....
<a href="#" data-role="button" id="login" data-theme="a" onclick="Login()">Log In</a>
....
<div class="bg" data-role="page" id="home" data-theme="b">
....

您可以像这样使用 window.location :

window.location='same_page_url#id_of_the_div';