I have a page that has a lot of (necessary) tabs, so it does a lot of calls to get the info but I only want to get that information only if that tab is clicked.
I have something like this:
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top"><a class="ui-tabs-anchor" href="#listing-global-view">@Resources.GetResourceString("Strings", "GlobalView")</a></li>
...
</ul>
<div id="listing-global-view" class="startup-active ui-tabs-panel ui-widget-content ui-corner-bottom">
@{Html.RenderPartial("ListingGlobalView", Model);}
</div>
Then my script initializes the tabs, but I only want the content associated to each tab when it's clicked.
$('.tabbedwidget').tabs({
active: 0,
activate: function (event, ui) {
var selectedSelector = ui.newPanel.selector; //ui.newTab[0].innerText;
switch (selectedSelector)
{
case "#listing-global-view": {
//make ajax equivalent to @{Html.RenderPartial("ListingGlobalView", Model);}
}
}
}
});
UPDATE
Now I have another problem: since I only want the info associated to that tab be rendered on click, I changed the href tag to the action that renders the partial.
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top"><a class="ui-tabs-anchor" href="@Url.Action("ListingGlobalView", new { id = Model.ID })">@Resources.GetResourceString("Strings", "GlobalView")</a></li>
...
</ul>
When the tab is clicked it shows properly my partial view but inside this partial, I'm calling another partial that was supposed to call another actions (to fill combo information - json), but they're not doing it. The info only comes correctly when I say at my controller the 1st partial rendered is a view, but that way it renders me the layout...
Thanks.