I have a tab menu where users can add and delete tabs like they want. When creating a new tab, they name it as they like (a bootstrap modal box opens for that). After naming the tab the tab gets created, but I don’t know what to do with the content. I need to load the same content for every tab added, I’v tried all sorts of scripts that I’v found online, but nothing seems to work.
This is the jQuery that I use:
$('.tabs a:last').tab('show');
$('#createTab').click(function() {
/* opens the modal box */
$('#tabModal').modal();
});
/* after clicking on a link Submit that has the id of newTab */
$('#newTab').click(function(){
var title = $('#myInput4').val();
$('#tabHeaders')
.append($('<li><a href="#' + title + '" class="tabs"><h1>'+ title +'<i class="icon-remove"></i></h1></a></li>'));
$('#myTabContent') /* this way adding content does not really work */
.append($('<div class="tab-pane fade in active" id="'+ title +'"></div>'));
$(title).tab('show');
});
/* tab delete */
$('.tabs i.icon-remove').live('click', function() {
$(this).closest('li').remove();
});
HTML for adding button:
<ul class="nav nav-tabs" id="tabHeaders">
<li><a href="#" data-toggle="tab" id="createTab"><h1> <i class="icon-plus"></i> </h1></a></li>
</ul>
I would appreciate if somebody could help me to load the content. I’ve created a file addTab.php that I would like to get loaded in the content part – when the user clicks on #createTab, first they choose the name for the tab and then the content gets loaded to that tab.
example test:
to add tab just do this :
try this please.