I've got a set of jQuery ui tabs that starts with one tab which is pre-poluated with data from another page. That works fine. What I am trying to do is create a series of links that when clicked will dynamically add a new tab, and load the new tab panel with the data in the link path. Here's the code:
$(function(){
var $tabs = $('#tabs').tabs({
add: function(event, ui) {
$tabs.tabs('select', '#' + ui.panel.id);
}
});
$('.add-tab').click(function(e){
e.preventDefault()
var tabName=$(this).text(),
tabNumber=-1;
$tabs.find('ul li a').each(function(i) {
if ($(this).text() == tabName) {
tabNumber = i;
}
});
if (tabNumber>=0)
$tabs.tabs("select",tabNumber)
else
$tabs.tabs("add",this.href , tabName )
return false
})
})
<a href="../views/subscribers.htm" class="add-tab">Subscribers</a>
<div id="tabs">
<ul>
<li><a href="../views/dashboard.htm">Dashboard</a></li>
</ul>
<div id="tabs-1">
</div>
</div>
So when you click the "Subscribers" link, it should add a new tab with the title "Subscribers", and load the data from "subscribers.htm" into the tab panel. Everything looks correct, so I'm not sure what's wrong here. Any help is appreciated.