facebook

Active Page

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #350416 Reply

    Nie Que
    Member

    Hi 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.

    #350420 Reply

    Code_A
    Member

    Here 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….

    #350421 Reply

    Nie Que
    Member

    i 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..
    }

    #350473 Reply

    Code_A
    Member

    Put 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.

    #350492 Reply

    Nie Que
    Member

    I 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
    }

    #350496 Reply

    Code_A
    Member

    Change 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);
    #350505 Reply

    Nie Que
    Member

    the 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’);
    }

    #350516 Reply

    Code_A
    Member

    The 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.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Active Page

You must be logged in to post in the forum log in