My goal is to overload Bootstrap nav pall click event, and I was happy to come across this post
I've modified the code the following way to make it work for pills, but I'm helpless to understand why it doesn't work.
HTML:
<ul class="nav nav-pills" id="orders_tab">
<li class="active"><a data-toggle="pill" href="#orders_for_today">Текущие</a></li>
<li><a data-toggle="pill" href="#orders_sent_to_vendors">Ожидающие</a></li>
<li><a data-toggle="pill" href="#inventories">Остатки</a></li>
<li><a data-toggle="pill" href="#sales">Продажи</a></li>
<li><a data-toggle="pill" href="#sales_aggregate">Аггрегированные продажи</a></li>
<li role="presentation" class="dropdown">
<a class="dropdown-toggle" data-toggle = "dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
Прочее <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#orders_products">Продукты</a></li>
</ul>
</li>
</ul>
JS
$('a[data-toggle="pill"]').on('shown.bs.pill', function (e) {
var target = $(e.target).attr("href") // activated tab
alert(target);
});
In Bootstrap nav-pills aka is a styling component not an js component. So data-toggle will be data-toggle="tab"
.
Update Fiddle for your code Fiddle
data-toggle="tab"
only change required.
-Help :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With