javascript - Bootstrap 3 data-target attribute on tab not working -
i using bootstrap tabs in website. when page loads tab filled data @ run-time using dynamic content. using data-target
attribute on anchor tag that, not seems work @ all.
here tried far:
html
<div class="container"> <div class="row"> <ul class="nav nav-tabs" role="tablist"> <li role="presentation" class="active"> <a href="showtab1.do" data-target="#test_1" aria-controls="test_1" role="tab" data-toggle="tab">tab 1</a> </li> <li role="presentation"> <a href="showtab2.do" data-target="#test_2" aria-controls="test_2" role="tab" data-toggle="tab">tab 2</a> </li> <li role="presentation"> <a href="showtab3.do" data-target="#test_3" aria-controls="test_3" role="tab" data-toggle="tab">tab 3</a> </li> </ul> <div class="tab-content"> <div role="tabpanel" class="tab-pane active" id="test_1"></div> <div role="tabpanel" class="tab-pane active" id="test_2"></div> <div role="tabpanel" class="tab-pane active" id="test_3"></div> </div> </div> </div>
here trying load content of remote file showtab1.do
inside div id="test_1"
when using data-target="#test_1"
on anchor tag. not working. know if using data-target don't need write jquery/javascript load data in tab data-target us(correct me if wrong). bootstrap version v3.3.6.
please correct me wrong.
there no way automatically load
data url tab content using data attributes. you'd need fire jquery load()
method when show tab event fires...
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) { ... $(target).load(url,function(result){ ... }); });
example: http://codeply.com/go/xzftnatkum
Comments
Post a Comment