Jquery ui选项卡隐藏div出现在主选项卡上

发布于 2024-10-11 06:19:31 字数 1980 浏览 6 评论 0原文

我不确定如何描述/询问这个问题,所以我会尽力而为。我正在 jquery 的选项卡中使用添加选项卡功能。在第一个选项卡上,我有一个 jqgrid,用于选择要在新选项卡中打开的项目。当选择一个项目时,新选项卡已成功创建,但在 jqgrid 下方添加了一个 div,如下所示(添加了空格)。我可能做错了什么导致这个幻像 div 出现?我使用 firebug 发现了这一点,但由于我还没有切换选项卡,所以应该不会显示任何内容,对吗?另外,似乎我为每个 addtab 创建了 2 个 div。 2正常吗?
编辑:2 不正常,示例代码不会在 jquery ui 网站上创建两个。

<div id="ui-tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"></div>

谢谢。

用于 addtab 的代码。

function addTab() {
    var selected_row = $grid.jqGrid('getGridParam',('selrow'));
    $tabs.tabs('add', selected_row, selected_row);
}

和选项卡模板。

tabTemplate: "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>",

编辑:基本上添加一个选项卡就是创建两个 div。奇数 ID 确实是需要的,偶数 ID 则不需要。 (id id =“ui-tabs-3”的div是正确的,但是还添加了另一个选项卡,其id =“ui-tabs-2”。不需要2。)我没有告诉它添加两个选项卡,偶数编号的内容是愚蠢的并且什么都没有,但我相信它会导致每次添加新选项卡时疯狂的空白出现并增长。有什么想法吗?我没有做任何复杂的事情,并且无法进一步分解代码,我认为如果不取消添加功能本身,就无法实现。

谢谢。

编辑:还有选项卡初始化的东西?我错过了一些明显的事情吗?看起来好像涉及 6 行代码,人们会认为我会看到我搞砸了什么?

var $tabs = jQuery("#tabs").tabs({
                    //tabTemplate: "<li><a href='http://localhost:8000/tickets/byId/#{href}/'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
                tabTemplate: "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
                ajaxOptions: {
                    error: function(xhr, status, index, anchor) {
                        jQuery(anchor.hash).html("If you're reading this then something didn't go right....oops.");
                    }
                }
            }).bind("tabsselect",function(event,ui){
                if (ui.index == 0) {
                    $grid.trigger('reloadGrid');
                }
            });

I'm not sure exactly how to describe/ask this so I'll give it my best shot. I am using add tab functionality in jquery's tabs. On the first tab I have a jqgrid which I use to select items to open in a new tab. When an item is selected the new tab is created successfully, but a div is added below the jqgrid which looks something like the following (white space added). What might I be doing wrong to cause this phantom div to show up? I found this using firebug, but since I haven't switched tabs yet nothing should be showing up right? Also, it appears that 2 divs are created for each addtab I do. Is 2 normal?
EDIT: 2 is not normal, the example code does not create two on the jquery ui website.

<div id="ui-tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide"></div>

Thanks.

Code used for addtab.

function addTab() {
    var selected_row = $grid.jqGrid('getGridParam',('selrow'));
    $tabs.tabs('add', selected_row, selected_row);
}

And the tab template.

tabTemplate: "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>",

Edit: Basically adding a tab is creating two divs. IDs that are odd are actually wanted, and even ids are not. (id a div with id="ui-tabs-3" is correct, but another tab is added as well which is of id="ui-tabs-2". The 2 is not wanted.) Nowhere am I telling it to add two tabs, and the even numbered stuff is dumby and has nothing, but I believe it is causing the crazy white space to appear and grow every time I add a new tab. Any ideas? I'm not doing anything complicated and can't pull code apart any further I don't think without taking away the add functionality itself.

Thanks.

Edit: And the tab init stuff as well? Am I missing something obvious? Seems like 6 lines of code involved and one would think I would see what I screwed up?

var $tabs = jQuery("#tabs").tabs({
                    //tabTemplate: "<li><a href='http://localhost:8000/tickets/byId/#{href}/'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
                tabTemplate: "<li><a href='#{href}'>#{label}</a><span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
                ajaxOptions: {
                    error: function(xhr, status, index, anchor) {
                        jQuery(anchor.hash).html("If you're reading this then something didn't go right....oops.");
                    }
                }
            }).bind("tabsselect",function(event,ui){
                if (ui.index == 0) {
                    $grid.trigger('reloadGrid');
                }
            });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

不…忘初心 2024-10-18 06:19:31

我相信这个错误回答了我的问题。

http://bugs.jqueryui.com/ticket/5069

I believe this bug answers my question.

http://bugs.jqueryui.com/ticket/5069

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