Move to another View in DojoMobile

640 Views Asked by At

i am developing a simple Hybrid application in IBM Worklight using DOJO.I have a Login Page and a Welcome Page. Once i press the login button it will go to function to check whether credentials are correct,if it is correct i want to mo to Welcome Page.

My code.. HTML

...
..
<button data-dojo-type="dojox.mobile.Button" id="loginBtn"
            style="margin-left: 50%; margin-top: 3%"
            data-dojo-props="label:'Login', onClick:function(e){loginCheck();}"></button>
...
..

.JS

. .. function loginCheck() { var username = uname.value; var password = pass.value;

if(username == "admin" && password == "admin")
    {
      //Move to another view
    }
else
    {
        alert("Incorrect Username or Password");
    }

} .. ..

Any help is appreciated..

2

There are 2 best solutions below

0
On

I use this code and it works

var w = dijit.byId('currentView');
w.performTransition('newView',1,"slide",null); //or #newView

Don't use alert, use this :

WL.SimpleDialog.show(
"My Title", "My Text", 
[{text: "First Button", handler: function() {WL.Logger.debug("First button pressed"); }
}]
)
0
On

You can use the performTransition method, see http://dojotoolkit.org/api/1.9/dojox/mobile/View

Hope this helps, Damien