Tab selection with jQuery in MVC
I have four tabs set in my view as follows
<ul>
<li><a id="#tabs-1">Case Summary</a></li>
<li><a id="#tabs-2">Patient</a></li>
<li><a id="#tabs-3">Physician</a></li>
<li><a id="#tabs-4">Site</a></li>
<li><a id="#tabs-5">Journal</a></li>
</ul>
What I need to do is be able to focus on the tag that my controller action requires by sending viewdata ("TabSelected") = "tabs-3" for doctors info
0
Charles
a source
to share
2 answers
It's much easier if you are using jQuery UI tabs. jQuery UI is a fully supported set of widgets for building client-side UI. One of the widgets is the tab widget.
Assuming you are using this, you can do something simple:
In controller action:
ViewData("SelectedTabIndex") = 1;
On the client side, in $ (document) .ready:
$('#myTabs').tabs({ selected: <%= ViewData["SelectedTabIndex"] %> });
+2
a source to share