Jump to content

jquery select elements inside bootstrap inactive nav tab?


Go to solution Solved by requinix,

Recommended Posts

This is a pretty general question, but I'm hoping for a best way suggestion before I go off and code a 1000 lines which will have to be redone.  Even a 'Yah, this is the best way to do this' would be appreciated from someone who's done this before.

 

Can you possibly get at elements inside a Bootstrap inactive nav nav-tabs element?  I have a 'workbench' with multiple nav-tabs.  When I change something in a active tab, I need to update a div element in other inactive tabs.  Makes sense you can't see it.  Is there a way to, or is the nav truly not loaded? (You can see all the html for all the tabs in the page, it must be 'hidden'?)

If that's so, I would need to rely on a tab load event and let that tab refresh itself.  Right?  Put the updated data in a form that is available to all tabs and populate this form with hidden values.  Is that the way to do this?
 

Thanks for any suggestions.

If you can inspect the HTML on the page, live not just with View Source, and it has the right combination of IDs and/or classes then yes, you can. And I'm 95% sure that will be the case for you.

 

Knowing the actual HTML structure would make it easier to say what the selector you'd need is.

Here's a stripped down example of what I have.  Whole html pages (the content of each tab) are assigned to variables and those variables are echoed within the tab content area.  Everything works as expected except js executed by one tab (the active tab) cannot see elements in others (inactive tabs).  All the js used by all the tabs are contained in <head>.

 

'select' tab js attempt to modifiy 'adjust' tab element <div id='idd_testadj' ... will fail.

 

'select' tab js can manipulate it's own elements.

 

It appears that the Bootstrap class has hidden content and I don't know how to get at it.

// Stripped down exmample
$tab_create_content  = "<div id='idd_testselect'>select me</div>";
$tab_adj_content     = "<div id='idd_testadj'>adjust me</div>";

Standard html begin HERE

<div class='container'>
   <div class='row'>
      <div class='col-md-1'></div>
      <div class='col-md-10'>
         <div class='bs-example'>
            <ul class='nav nav-tabs' id='myTab' >
               <li class='active'><a data-toggle='tab' href='#sectionselect' >Select</a></li>
               <li><a                data-toggle='tab' href='#sectionadjust' >Adjust</li>
            </ul>
            
            <div class='tab-content'>
               <div id='sectioncreate' class='tab-pane fade in active'>
                  <br>
                  <?php echo $tab_create_content;?>
               </div> <!-- end tab content create -->
               <div id='sectionadjust' class='tab-pane fade'>
                   <br>
                   <?php echo $tab_adj_content;?>
               </div>               
            </div> <!-- tab-content -->
            
         </div> <!-- bs-example -->
      </div> <!-- div 10 -->
      <div class='col-md-1'></div>
   </div> <!-- row -->
</div> <!-- container -->

standard html end HERE
  • Solution

Then I'd say you can forget about the nav thing. That only shows and hides content - it still exists on the page, so you can certainly manipulate it whenever and however you want.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.