1

I am using bootsrap tab.I have actually three sections.By default section one is selected.Suppose if I move to section 2 then data of section 2 should be refreshed. Actually I have registration form in section 1 and in section 2 to view the resgitered users.So suppose i entered some details in section 1 then it is inserted into database.Now unless I refresh the section 2,I wont get new values from DB.Please tell me how to refresh.Alternate solutions are also welcome

<div class="tabbable" id="myTabs">
  <ul class="nav nav-tabs">
    <li><a id="tabAll">All</a></li>
    <li class="active"><a href="#tab1" data-toggle="tab">Section 1</a></li>
    <li><a href="#tab2" data-toggle="tab">Section 2</a></li>
    <li><a href="#tab3" data-toggle="tab">Section 3</a></li>
  </ul>
  <div class="tab-content">
    <div class="tab-pane active" id="tab1">
      <p>I'm in Section 1.</p>
    </div>
    <div class="tab-pane" id="tab2">
      <p>Howdy, I'm in Section 2.</p>
    </div>
    <div class="tab-pane" id="tab3">
      <p>Howdy, I'm in Section 3.</p>
    </div>
  </div>
</div>
<script>
$('#tabAll').click(function(){
  $('#tabAll').addClass('active');  
  $('.tab-pane').each(function(i,t){
    $('#myTabs li').removeClass('active'); 
    $(this).addClass('active');  
  });
});
</script>
SpringLearner
  • 13,738
  • 20
  • 78
  • 116

2 Answers2

1
  1. You can use location.hash to manipulate tab selection accordingly.
  2. Or use Sammy js
  3. Localstorage is another option, refer this
Community
  • 1
  • 1
Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
1

When you click on section 2 tab make an ajax call to your DB in order to fetch new values. Another option is to do the refresh after you submit your form (I assume that you also do it using ajax) simply load a new content to "#tab2" div in ajax success handler of your form submission event

Alex Art.
  • 8,711
  • 3
  • 29
  • 47
  • +1 for helping.Well I thought of using ajax but I dont know why ajax is not working in bootstrap.Though I know ajax has nothing to do with bootstrap.please see this link(i have posted yesterday) http://stackoverflow.com/questions/19494510/jsp-ajax-not-working – SpringLearner Oct 22 '13 at 06:06
  • Can you please try to solve the question http://stackoverflow.com/questions/19494510/jsp-ajax-not-working – SpringLearner Oct 22 '13 at 06:15
  • Check my answer to http://stackoverflow.com/questions/19494510/jsp-ajax-not-working – Alex Art. Oct 22 '13 at 06:29