选项卡面板父元素折叠时的 jQuery UI 选项卡难题

发布于 2024-10-09 19:07:45 字数 2834 浏览 6 评论 0原文

我正在构建一个使用 jQuery UI 选项卡的面板控件,如下所示:

alt text

选项卡位于标题和选项卡面板嵌套在父元素内的单个包含 (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:

alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ杯具 2024-10-16 19:07:45

我明白问题出在哪里了。显然我有一个额外的锚标记被添加到li.handle_button元素中,这个锚标记与选项卡无关,而是用于自定义的。这个标签的存在就给 jQuery 选项卡行为带来了麻烦。我将此元素更改为跨度,现在一切正常。

I figured out what the problem was. Apparently I had an extra anchor tag that was being added into the li.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文