Reputation: 1668
I have to pass the id of selected tab when another action occurs
<ul class="nav nav-tabs" id="myTab">
<li <?php if($all_index== 1){?> class="active" <?}?> ><a href="#tab1" data-toggle="tab">All</a></li>
<li <?php if($select_index== 1){?> class="active" <?}?>><a href="#tab2" data-toggle="tab">Selected</a></li>
<li <?php if($reject_index== 1){?> class="active" <?}?> ><a href="#tab3" data-toggle="tab">Rejected</a></li>
</ul>
I have a dropdown to filter the tab data..First tab is always active.
If i want to filter the second tab,then i click the dropdown the action occur..but the tab selected is first one..I want the Second one
Upvotes: 0
Views: 1583
Reputation: 11987
If you are looking to capture the value on form submit, create a hidden field in your form. So every time on click, capture the id of the tab and store in hidden field.
<input type="hidden" id-"hidden" name="tab-selected" />
In script
$(document).on("click","#myTab a",function() {
var sel = $(this).attr("href");
$("#hidden").val(sel);
});
so on form post, you will get the selected tab's value.
Here is the fiddle demo
Upvotes: 1
Reputation: 38662
In View
<ul class="nav nav-tabs" id="myTab">
<li <?php if($tab_index== 1){?> class="active" <?}?> ><a href="<?php echo base_url() ?>Controller/FunctionName/1" data-toggle="tab">All</a></li>
<li <?php if($tab_index== 2){?> class="active" <?}?>><a href="<?php echo base_url() ?>Controller/FunctionName/2" data-toggle="tab">Selected</a></li>
<li <?php if($tab_index== 3){?> class="active" <?}?> ><a href="<?php echo base_url() ?>Controller/FunctionName/3" data-toggle="tab">Rejected</a></li>
</ul>
in Controller
public function FunctionName($value)
{
# code...
// pass which id should be active alone with data
}
Upvotes: 0