选项卡面板父元素折叠时的 jQuery UI 选项卡难题
我正在构建一个使用 jQuery UI 选项卡的面板控件,如下所示:
选项卡位于标题和选项卡面板嵌套在父元素内的单个包含 (div.form-panel-contents
) 下,我用它来展开/折叠面板内容。问题是,当我通过 SlideUp 折叠包含的 div 时,Tabs 会以某种方式检测到选项卡面板容器不可见,并将 CSS 类 ui-tabs-hide
应用于每个嵌套选项卡面板,这会设置所有选项卡面板均显示:无
。
我的问题是当父div折叠时如何阻止它应用ui-tabs-hide
类?
当我更改包含div的状态时我想要的状态选项卡面板保持完整,以便向上/向下滑动看起来流畅。我也很好奇该工具如何检测到父元素首先被折叠。
代码:
if ($.fn.tabs)
$(".ui-tabs").tabs();
-
<div class="widget ui-tabs form-panel-container">
<ul class="title_bar">
<li class="handle"><h5>New Panel Look - Test <span class="asterisk"></span></h5></li>
<li class="leaf"><a class="leaf_link" href="#tab_name_1">Tab Name 1</a></li>
<li class="leaf"><a class="leaf_link" href="#tab_name_2">Tab Name 2</a></li>
<li class="leaf"><a class="leaf_link" href="#tab_name_3">Tab Name 3</a></li>
<li class="handle_buttons"><a href="" class="handle_btn expand"></a><a href="" class="handle_btn question"></a></li>
</ul>
<div class="form-panel-contents">
<div>
<div id="tab_name_1">
<div class="text_area">
<div class="padder">
<p> content content content content content content content content content content content content content content content content content content</p>
</div>
</div>
<div class="action_bar">
<div class="pad">
<a href="" class="btn"><label></label>Name of Button</a>
</div>
</div>
</div><!-- end wrapper div -->
<div class="text_area" id="tab_name_2">
<div class="padder">
<textarea>content content content content content content content content content content content content</textarea>
</div>
</div>
<div class="text_area" id="tab_name_3">
<div class="padder">
<h5>Input Something<span class="asterisk"></span></h5>
<div class="title_container"><input type="text" id="title"></div>
</div>
</div>
</div>
</div>
</div>
I'm building a panel control that makes use of jQuery UI tabs, and looks like this:
The tabs are in the header and the tab panels are nested inside the parent element under a single containing (div.form-panel-contents
) that I use for expanding/collapsing the panel contents. The problem is when I collapse the containing div via slideUp, somehow Tabs detects that the tab panels container is not visible and applies the CSS class ui-tabs-hide
to each of the nested tab panels, which sets all tab panels to display: none
.
My question is how can I stop it from applying ui-tabs-hide
class when parent div is collapsed?
When I change the state of the containing div I want the state of the tab panels to remain intact, so that the slide up/down looks fluid. I'm also curious how the tool even detects that the parent element was collapsed in the first place.
Code:
if ($.fn.tabs)
$(".ui-tabs").tabs();
-
<div class="widget ui-tabs form-panel-container">
<ul class="title_bar">
<li class="handle"><h5>New Panel Look - Test <span class="asterisk"></span></h5></li>
<li class="leaf"><a class="leaf_link" href="#tab_name_1">Tab Name 1</a></li>
<li class="leaf"><a class="leaf_link" href="#tab_name_2">Tab Name 2</a></li>
<li class="leaf"><a class="leaf_link" href="#tab_name_3">Tab Name 3</a></li>
<li class="handle_buttons"><a href="" class="handle_btn expand"></a><a href="" class="handle_btn question"></a></li>
</ul>
<div class="form-panel-contents">
<div>
<div id="tab_name_1">
<div class="text_area">
<div class="padder">
<p> content content content content content content content content content content content content content content content content content content</p>
</div>
</div>
<div class="action_bar">
<div class="pad">
<a href="" class="btn"><label></label>Name of Button</a>
</div>
</div>
</div><!-- end wrapper div -->
<div class="text_area" id="tab_name_2">
<div class="padder">
<textarea>content content content content content content content content content content content content</textarea>
</div>
</div>
<div class="text_area" id="tab_name_3">
<div class="padder">
<h5>Input Something<span class="asterisk"></span></h5>
<div class="title_container"><input type="text" id="title"></div>
</div>
</div>
</div>
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白问题出在哪里了。显然我有一个额外的
锚标记
被添加到li.handle_button
元素中,这个锚标记与选项卡无关,而是用于自定义的。这个标签的存在就给 jQuery 选项卡行为带来了麻烦。我将此元素更改为跨度,现在一切正常。I figured out what the problem was. Apparently I had an extra
anchor tag
that was being added into theli.handle_button
element, this anchor tag was not related to tabs but was for something custom. Just the presence of this tag threw a wrench into the jQuery tabs behavior. I changed this element to a span and now everything works great.