- This topic has 7 replies, 2 voices, and was last updated 10 years, 9 months ago by
Code_A.
-
AuthorPosts
-
Nie QueMemberHi everyone, Im making a fuction that will change the image of my tabbar once the Home page of my multipage is active and will change again once the other page is active. Im having trouble with my web app using mobione.
my problem is i dont know how to call the active page that’s being click on the tabbar.
Is there any code that will call the active page that’s being click on the tabbar??
is there anyone who could help me with this. thank you.
Code_AMemberHere is the MultiPage Widget documentation which shows you how to track the old page and the new page. Although, I am not sure you can change the tabbar images dynamically….
Nie QueMemberi already tried to change the image on the tabbar i just need to know on how to call the page being click so i can trap it and change the image of it once the page is on…
Ive seen the multipage tutorial that you link. but i dont really understand how would i call the page.
i have a logic here that:
if(pagehome==active)
{
imagechange()
}
else
{
some code..
}
Code_AMemberPut the code below in your Multipage widgets Run Javascript window for On Page Change and see if it works.
var activePage = $(newPage).attr('id'); //you can also use oldPage here if you want to know the previous page if (activePage == 'm1-<your-screen>-page1') { imagechange(); }else{ //some other code }
If you need the variable to be tracked throughout your app, then declare the activePage variable in your _custom.js to make it global. If you do that then you will need to remove the ‘var’ declaration from the code above otherwise it will only be available locally to the On Page Change event.
Nie QueMemberI tried to put the code ON PAGE CHANGE it it doesn’t work.
here’s my code
var activePage = $(newPage).attr(‘Home’); //Home is the id of the page on multipage
if (activePage == ‘m1-multiPage-Home’) {
imagechange();
}else{
//some other code
}
Code_AMemberChange the first line of your code back to $(newPage).attr(‘id’) and it should work. The code is grabbing the ‘id’ property of the new page, which in your case it will return ‘Home’.
If you want to see what the activePage value is then add the following code after the call:
alert(activePage);
Nie QueMemberthe code work fine but when i add 2 more conditions. it won’t read my function anymore. Is there anyway to work this out with more than 3 conditions??
activePage = $(newPage).attr(‘id’);
if (activePage == ‘m1-myproject-Page1’)
{
alert(activePage);
}
else if(activePage == ‘m1-myproject-Page2’)
{
alert(activePage);
}
else if(activePage == ‘m1-myproject-Page3’)
{
alert(activePage);
}
else
{
alert(‘do nothing’);
}
Code_AMemberThe conditional statement does not have a limit on how many conditions can be compared. Double check your code to make sure there is not a syntax error in the statement.
-
AuthorPosts