1
I have five tabs, and each one displays or not the result of a query in the bank.
<div class="container">
<ul class="nav nav-tabs">
<li class="active">
<a data-toggle="tab" class="nav-link" href="#basic">Basic</a>
</li>
<li class="nav-item">
<a data-toggle="tab" class="nav-link" href="#gold">Gold></a>
</li>
.
.
.
</ul>
the basic tab is activated when you load the page:
<script>
$(document).ready(function(){
$('a[href="#basic"]').tab('show');
});
</script>
It happens that as each tab is the result of a query, it may occur that the "basic" tab does not contain any data to display, and the other yes.
I’m looking for a solution to display the first tab with result, by loading the page
NOTE: I use Listview to display the data.
What is the HTML of the tab?
– Sam
<div class="tab-content"> <div id="basic" class="tab-pane fade in active">
– Daniel
Try this:
$(document).ready(function(){
 $('.tab-pane').each(function(){
 if($(this).children().length){
 $('a[href="#'+ this.id +'"]').tab('show');
 return false;
 }
 });
});
– Sam
@Sam opened the tab "basic", which is the first one. In the test, this tab could not open, because it did not contain data of the query, and the others yes. Returned only the Listview <Emptydatatemplate> return message.
– Daniel
Will checking whether it contains any text in the tab works?
– Sam
i have these variables on the page that show whether or not the tab has data: <% Response.Write(Basic);%> and so on for each of the five tabs. I think these variables can help solve the problem.
– Daniel
Let’s go continue this discussion in chat.
– Sam