- This topic has 8 replies, 3 voices, and was last updated 12 years, 5 months ago by support-octavio.
-
AuthorPosts
-
willMembertrying to have a a password protected screen. here is my javascript applied to the custom js file in the generated source codes library:
phoneui.prePageTransition = function(currentPageId,targetPageId) {
if(currentPageId == ‘#m1-salesperson_password_entry’ && $(‘#m1-salesperson_password_entry-passwordField1′).text==’password’)
return true;
}it doesn’t work, i think due to syntax errors. if anyone could neaten the javascript for me or support could provide a password implementation example, similar to the excellent custom and select list examples, that would be great.
thanks
Max87MemberHi will
I’ll try to help…
Try to modificate your code like this:
var enteredPassword = $(“#m1-salesperson_password_entry-passwordField1″).val();
if(currentPageId == ‘#m1-salesperson_password_entry’ && enteredPassword ==”password”)
{
return true;
}
else
{
return false;
}Can you please test it and let me know if it works?
willMemberthanks for the help max unfortunately this doesn’t appear to work for me 🙁 upon transition the page changes irregardless of the password entered.
support-octavioMemberHi will,
I’ve tested the next code and is working fine for me:
phoneui.prePageTransition = function(currentPageId,targetPageId) { // add custom pre-transition code here // return false to terminate transition var enteredPassword = $('#m1-home-textField1').val(); if(currentPageId == '#m1-home' && targetPageId == '#m1-welcome') { if(enteredPassword !="123"){ alert("invalid password"); return false; } } return true; }
Note that if you use this in webapps, anybody with javascript knowleadge could find the password.
willMemberthanks for the help.
the code works great however i am having a problem as code is in the pre transition area with some other codes :
phoneui.prePageTransition = function(currentPageId,targetPageId) {
// add custom pre-transition code here
// return false to terminate transition
{
function();
}if (currentPageId == ‘#m1-name’) {
another function();
}if(currentPageId == ‘#m1-salesperson_password_entry’ && targetPageId == ‘#m1-Contract_Summary’)
{var enteredPassword = $(‘#m1-salesperson_password_entry-passwordField1’).val();
if(enteredPassword !=”123″){
alert(“invalid password”);
return false;
}}
return true;
}
and this has caused the invalid password message to work but the page transition not to even if password is correct (all other functions perform fine). will i have to put the code elsewhere or is this a bug/syntax problem?
support-octavioMemberHi will,
I don’t think this is a bug. Could you check if this is a syntax error in DOM Inspector?
Also, please try to move the condition for the login at the begin of phoneui.prePageTransition
willMemberive tried using the dom inspector and the debugger but as ive only been doing java for the last few weeks i havent found it really tells me anything. tried using an if true option contained in the code next to the if alert false but that didn’t work. also tried making it an function in the document readyhandler but nothing seems to work. will keep looking and post if i find out what i’m doing wrong.
willMemberive managed to get it to work by taking out the line that shows the alert I don’t know why this makes it work though
for anyone else with this problem amended code:var enteredPassword = $(‘#m1-your page’).val();
if(currentPageId == ‘#m1-your page’ && targetPageId == ‘#m1-yourpage2’)
{
if(enteredPassword !=”yourpassword”){
return false;
}
support-octavioMemberHi will,
Glad that you got that your functionality works.
-
AuthorPosts