My Phonegap application login page contains a few input fields like username, password, url, device type, etc… that the user has to enter to activate the application when he logins for the fist time. The next time on the user has to enter only the username and password as the application is already activated. So I want to display only the username and password fields the second time on login.
I have a phonegap plugin to check whether the app is activated or not. I want to call this plugin and based on the callback response I will show only necessary fields on the login page.So what would be the easiest way to do this?
I tried this..
$("#loginPage").live('pagebeforeshow',function(event, ui){
window.plugins.AuthPlugin.appIsActive(appIsActiveCallBack);
});
function appIsActiveCallBack(result){//Show only relative fields...}
But I got this error:Uncaught TypeError: Cannot call method ‘appIsActive’ of undefined
Thanks in advance.
You are getting
Uncaught TypeErrorbecause you are trying to call the plugin before even the device is ready… Call the Plugin only when the device is ready…UPDATE
What you have to do is to determine what all fields you need to show in native side only…
After that pass a variable(flag) from java to JavaScript which will be accessible at pagebeforeshow
So your Activity will look like something like this
And in your index.html show like this
After that with the use of flag you can determine what to show and what not to…
Hope it helps…