facebook

Get id of current multipage tab panel?

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

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

    rick.gommers
    Member

    Hi all,

    I have an app where my user has to choose between 4 possibilities. These choices are in seperate tabs in a multipage widget.

    To be able to do something with their choices I need to know the current tab id when the user clicks a button.

    Would there be an easy way to get this information?

    Thx in advance!

    #346607

    Brandon
    Member

    just off hand you can always use a function to return the id of the object clicked;

    //off the top of my head, untested
    function getMyID()
    {
    alert(event.target.id);//should return object clicked id, button, image, etc
    }

    Im not at my dev system, but there is probably also a way to get the current active page using the css attributes or something.

    #346611

    Code_A
    Member

    Below is a snippet of code that can be used to determine the page id’s. You can place the code in the On Page Change or the On Page Changing actions of the multipage widget. More information can found in the Creating a Multi-Page UI with a Fixed Tab Bar tutorial.

    //acquiring the page id
    alert ($(newPage).attr('id'));
    alert ($(oldPage).attr('id'));
    #346612

    Brandon
    Member

    Thanks CodeA, I knew there was something like that but couldn’t think of it.

    #346616

    rick.gommers
    Member

    Thx CodeA, that was exactly what I needed!

    #346625

    rick.gommers
    Member

    I feel stupid. I try to replicate the if (pageId.endsWith(‘page1’)) method from here: https://www.genuitec.com/mobile/docs/tabbedNavigation/tabbedNavigation.html

    This doesn’t work. I get TypeERror: Object page1 has no method ‘endsWith’.

    I tried to make sure it was a string by stringifying it, to no avail.

    I guess I’m missing something obvious here?

    Edit: I like your captcha! Finally someone has created something else then those fkn numbers every time 🙂

    #346627

    Code_A
    Member

    I have never tried to use that function. Instead, how about just doing a comparison check using ifs or case statements?

    if ($(newPage).attr('id') == '<page-name>'){
    
    }else if ($(newPage).attr('id') == '<page-name>'){
    
    }else{
    
    }
    #346629

    rick.gommers
    Member

    Ah Thx m8. You brought me of the idea to use indexOf to compare the pageId with my ‘endsWith’ text. Less code rewriting 😀

    Here’s how I’ve done it:

    function pageChanged(pageId) {
        
        if(pageId.indexOf('tabid20mm') != -1 ) {
    
        } else if (pageId.indexOf('tabid25mm') != -1 ) {
    
       }
    }
Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Get id of current multipage tab panel?

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