简体   繁体   English

如何使用jQuery UI和Rails将选项卡设置为自定义选项卡

[英]how to set tab to a custom tab using jquery ui and rails

I'm using jqueryUI for tabs on a page. 我将jqueryUI用于页面上的选项卡。 I initialize it like below: 我将其初始化如下:

$("#tabs").tabs();

<div id="tabs">
    <ul>

      <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. 我有两个问题。

  1. How do I set the tab to be custom. 如何将标签设置为自定义。 say I want second tab to be shown first. 说我想先显示第二个标签。 $('#tabs').tabs(2) does not work. $('#tabs').tabs(2)不起作用。 i got that from this link 我从这个链接得到的

  2. Let say I click on a button inside tab1. 假设我单击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中,我单击某项...返回操作...,然后我想回到选项卡2。

1. Is there an error when you call $('#tabs').tabs(2) ? 1.调用$('#tabs').tabs(2)时是否出错?

2. You can set a variable in your controller that tells the view which tab to be active. 2.您可以在控制器中设置一个变量,该变量告诉视图哪个选项卡处于活动状态。

#controller
... do some stuff
@current_tab = 2


#view
$('#tabs').tabs(<%= @current_tab %>)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM