Jquery 选项卡,在 Firefox 中重新加载 jQuery HTML 后,未格式化的列表会闪烁
我正在使用最新的 jQuery 选项卡,并且我的所有选项卡(以及它们上面的其他内容)都位于包含 Div 中。其中一个选项卡中有一个表单,当表单提交时,通过 AJAX 对其进行处理,然后返回的 HTML 替换整个包含的 Div。返回的 HTML 再次包含选项卡。
替换 HTML 后,我将 jQuery 功能重新绑定到列表:
$('#tabs').tabs( { fx: { opacity: 'toggle' } } );
阅读其他问题后,我在 UL 和 class="ui-tabs 上使用
在 LI 上,在格式化之前隐藏所有内容。class="ui-tabs"
-hide"
在 IE8 和 Chrome 中,这工作正常。然而,在 Firefox 中,未格式化的列表在 HTML 刷新和正在格式化的选项卡之间短暂显示(在第一次加载时也非常短暂)。
请问有什么办法可以避免这种情况吗?
I am using the latest jQuery Tabs, and all of my tabs (and other content above them) are within a containing Div. There is a form in one of the tabs, and when the form is submitted, it is processed via AJAX, and then the returned HTML replaces the entire containing Div. This returning HTML includes the tabs again.
After the HTML is replaced, I rebind the jQuery functionality to the list:
$('#tabs').tabs( { fx: { opacity: 'toggle' } } );
Having read other questions, I am using class="ui-tabs"
on the UL and class="ui-tabs-hide"
on the LI, to hide everything before it's formatted.
In IE8, and Chrome this is working fine. However in Firefox, the unformatted list is showing briefly between the HTML refresh and the tabs being formatted (it does very briefly on the first load too).
Any ideas how to avoid this please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
来自 jQueryUI 文档:
class="ui-tabs-hide"
应该出现在每个面板上,而不是选项卡列表项上。这不一定能修复列表未样式化的问题;如果您正确实现上述内容并且仍然获得 FOUC,则应该隐藏列表的父元素,直到加载新内容并对列表进行制表。您可以使用 $().hide() 和 .show() 方法来执行此操作。
From jQueryUI docs:
The
class="ui-tabs-hide"
should go on each panel, not the tab list items.This won't necessarily fix the list being unstyled; If you're implementing the above properly and still getting the FOUC, you should hide the list's parent element until you have loaded the new content and tabify'd the list. You could use the $().hide() and .show() methods to do this.
我刚刚遇到了类似的问题,我发现适用于选项卡式导航的另一个解决方案是将“ui-tabs-nav”类添加到选项卡导航中的
标记中,(即
),如下所示:
Jquery 选项卡脚本在脚本触发时自动将“ui-tabs-nav”类添加到
中,但您可以手动将其放入 html 中,选项卡的相关 css即使加载选项卡脚本存在延迟,也会插入菜单。希望这有帮助!
I just had a similar problem, another solution I found that worked for the tabbed navigation is to add the "ui-tabs-nav" class to the
<ul>
tag in the tab nav, (i.e.<ul class = "ui-tabs-nav">
), which looks as follows:The Jquery tab script adds the "ui-tabs-nav" class to the
<ul>
automatically when the script fires, but by putting it in yourself manually into the html, the relevant css for your tab menu will be inserted, even when there is a delay in the tab script being loaded. Hope this helps!HeyPops 使用
visibility
属性的一种变体,但在 CSS 样式表中:利用.tabs()
初始化后添加的类,例如.ui-tabs
类。 CSS 示例:然后只需将该类 (
tab-this
) 添加到您进行 Tab 化的 div 以及整个网站中的任何其他选项卡式内容。A variation to HeyPops' use of the
visibility
property, but in your CSS stylesheet: leverage the classes that get added after.tabs()
is initialized, such as the.ui-tabs
class. Example CSS:And then just add that class (
tab-this
) to the div that you tab-ify, and any other tabbed content throughout your site.这似乎并不总是有效。我建议使用 Kelso.b 答案而不是 jQuery 文档解决方案。这是一个例子。
然后稍后在 jQuery 选项卡中添加 show 方法。
This does not seem to work all the time. I recommend to use Kelso.b answer rather than the jQuery docs solution. Here is an example.
Then later in jQuery tabs add the show method.
从我所看到的情况来看,此解决方法的运行更加干净,因为它还可以防止 UL 出现。将 style="visibility:hidden" 添加到包含 UL 和所有选项卡窗格的 DIV,如下所示:
然后当您对 DIV 进行选项卡化时,使其可见之后它的格式如下:
使用 visibility:hidden 而不是 display:none 意味着选项卡 DIV 内的所有元素都将具有大小和位置,而 则不然>显示:无。
This workaround operates much cleaner from what I can see as it also prevents the UL from appearing. Add style="visibility:hidden" to the DIV which contains the UL and all tab panes, like this:
then when you tab-ify the DIV, make it visible after it's been formatted, like:
Using visibility:hidden rather than display:none means all the elements inside the tab DIV will have size and position which is not the case with display:none.