I have this jQuery UI Tabs model with only 2 tabs and I need the content to load through Ajax. The problem is that these tabs are loaded inside a jQuery UI Dialog and mid
is dynamic. I mean, the dialog is launched by clicking a link (which contains mid=X
).
The code is something like this:
Javascript:
$('.item-movie-link').each(function() {
$(this).parent().click(function() {
$('#tabs-movie li a[href$=info]').attr('href', $(this).attr('href') + '&op=info');
$('#tabs-movie li a[href$=cast]').attr('href', $(this).attr('href') + '&op=cast');
$('#dialog-movie-info').dialog('open');
$('#tabs-movie').tabs();
return false;
});
});
HTML:
<div id="dialog-movie-info">
<div id="tabs-movie">
<ul>
<li><a href="#tab-info"><img src="template/images/icon-tab-movie-info.png" alt="" />Information</a></li>
<li><a href="#tab-cast"><img src="template/images/icon-tab-movie-cast.png" alt="" />Cast List</a></li>
</ul>
</div>
</div>
This works when I first click one of those .item-movie-link
's, but after closing the dialog and clicking another link, it will not work, the same information will be displayed.
How can I make this work? Maybe there's a better approach for this?
My problem was fixed by destroying the jQuery UI Tabs on the close
event of the jQuery UI Dialog:
$('#tabs-movie').tabs('destroy');