how to set tab to a custom tab using jquery ui and rails
I'm using jqueryUI for tabs on a page. I initialize it like below:
$("#tabs").tabs();
<div id="tabs">
<ul>开发者_StackOverflow中文版
<li><a href="#tabs-4">Part A</a></li>
<li><a href="#tabs-2">Part B</a></li>
<li><a href="#tabs-5">Part C</a></li>
</ul>
<div id="tabs-4">
.....
</div>
<div id="tabs-2">
....
</div>
<div id="tabs-5">
....
</div>
</div>
I have 2 questions.
How do I set the tab to be custom. say I want second tab to be shown first.
$('#tabs').tabs(2)
does not work. i got that from this linkLet say I click on a button inside tab1. Clicking on the button takes control back to an action and then control comes back to this page. When the control comes back...then is it possible to set a custom tab?. For example. in tab 1 I click something...go back to the action...and then I want to come back to tab 2.
1.
Is there an error when you call $('#tabs').tabs(2)
?
2. You can set a variable in your controller that tells the view which tab to be active.
#controller
... do some stuff
@current_tab = 2
#view
$('#tabs').tabs(<%= @current_tab %>)
精彩评论