I am looking to incorporate ajax tabs using vue js. Each tab will need an ajax request to fetch both the template and data from an api.
Here is an example of the tabs:
<div id="tabs">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab1" role="tab" data-toggle="tab">Tab1</a></li>
<li><a href="#tab2" ajax-url="/tab2" role="tab" data-toggle="tab">Tab2</a></li>
<li><a href="#tab3" ajax-url="/tab3" role="tab" data-toggle="tab">Tab3</a></li>
<li><a href="#tab4" ajax-url="/tab4" role="tab" data-toggle="tab">Tab4</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="tab1"></div>
<div role="tabpanel" class="tab-pane" id="tab2"></div>
<div role="tabpanel" class="tab-pane" id="tab3"></div>
<div role="tabpanel" class="tab-pane" id="tab4"></div>
</div>
</div>
<script>
$('#tabs').on('shown.bs.tab', function (event) {
var url = event.target.getAttribute("ajax-url");
// fetch template and data..
// init vue instance for the new tab
})
</script>
What would be the most effective way to integrate vue into this setup? Should I create separate vue instances for each tab, or use components? Additionally, I require the ability to preload some of the tabs.
Given that I need to initialize the vue instances on demand, I am uncertain about the best approach to handle this. In angular, I would define ng-controller for each tab. However, with vue.js it seems there may not be a standardized project architecture.