无法获取嵌套的 jquery 选项卡

发布于 2024-08-04 11:17:10 字数 1679 浏览 3 评论 0原文

这是演示问题的完整示例脚本,内部选项卡公司/部门显示为列表而不是选项卡。

编辑: 我已经尝试过人们建议的内部选项卡也应该通过 jQuery 进行选项卡化,但

代码:

<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.tabs.js"></script>
<script type="text/javascript">
$(function(){
    //make tabs tabs
    $('#top-tabs').tabs({selected: 2});
});
</script>

</head><body>

<div id="top-tabs">
   <ul>
             <li><a href="/timeapp/home">Home</a></li>
             <li><a href="/timeapp/timecard">Timecard</a></li>
             <li><a href="#tab-selected">Config</a></li>
   </ul>

   <div id="tab-selected">
    <ul>
              <li><a href="#inner-tab-selected">Company</a></li>
              <li><a href="/timeapp/config/department">Department</a></li>
    </ul>
    <div id="inner-tab-selected">ok this is a company</div>

   </div>
</div>

</body></html>

Here is the full sample script which demonstrates the problem, inner tabs company/department come up as list instead of tabs.

Edit:
I have already tried what People have suggested that inner tabs should also be tabified via jQuery but

Code:

<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.tabs.js"></script>
<script type="text/javascript">
$(function(){
    //make tabs tabs
    $('#top-tabs').tabs({selected: 2});
});
</script>

</head><body>

<div id="top-tabs">
   <ul>
             <li><a href="/timeapp/home">Home</a></li>
             <li><a href="/timeapp/timecard">Timecard</a></li>
             <li><a href="#tab-selected">Config</a></li>
   </ul>

   <div id="tab-selected">
    <ul>
              <li><a href="#inner-tab-selected">Company</a></li>
              <li><a href="/timeapp/config/department">Department</a></li>
    </ul>
    <div id="inner-tab-selected">ok this is a company</div>

   </div>
</div>

</body></html>

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

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

发布评论

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

评论(2

时间海 2024-08-11 11:17:10

如果这是您的整个文件,那么问题是,您没有告诉它“选项卡选择”div 应该是选项卡。我还没有测试过,但添加一个 :

 $('#tab-selected').tabs();

可能会成功。

If this is your entire File, then the problem is, your not telling it that the "tab-selected" div is supposed to be tabs. I haven't tested it but adding a :

 $('#tab-selected').tabs();

would probably do the trick.

A君 2024-08-11 11:17:10

我在 jquery 论坛上发布了这个问题,得到了答案

原因是应该在所有内部选项卡上调用 elem.tabs() ,我给出的示例是通过使用 jQuery 选择器来实现的,例如 $('#container ul').tabs()< /code>,这是修改后的工作脚本:

<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.tabs.js"></script>
<script type="text/javascript">
$(function(){
    //make tabs tabs
    $('#top-tabs').tabs({selected: 2});
    $('#low-tabs').tabs({selected: 1});
});
</script>

</head><body>

<div id="top-tabs">
   <ul>
             <li><a href="/timeapp/home">Home</a></li>
             <li><a href="/timeapp/timecard">Timecard</a></li>
             <li><a href="#tab-selected">Config</a></li>
   </ul>

   <div id="tab-selected">
    <div id="low-tabs"> 
    <ul>
              <li><a href="#inner-tab-selected">Company</a></li>
              <li><a href="/timeapp/config/department">Department</a></li>
    </ul>
    <div id="inner-tab-selected">ok this is a company</div>
     </div> 
   </div>
</div>

</body></html> 

I posted the question at jquery forum and got the answer.

Reason is that elem.tabs() should be called on all inner tabs, the example I gave does it by using jQuery selector e.g. $('#container ul').tabs(), so here is the modified working script:

<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.tabs.js"></script>
<script type="text/javascript">
$(function(){
    //make tabs tabs
    $('#top-tabs').tabs({selected: 2});
    $('#low-tabs').tabs({selected: 1});
});
</script>

</head><body>

<div id="top-tabs">
   <ul>
             <li><a href="/timeapp/home">Home</a></li>
             <li><a href="/timeapp/timecard">Timecard</a></li>
             <li><a href="#tab-selected">Config</a></li>
   </ul>

   <div id="tab-selected">
    <div id="low-tabs"> 
    <ul>
              <li><a href="#inner-tab-selected">Company</a></li>
              <li><a href="/timeapp/config/department">Department</a></li>
    </ul>
    <div id="inner-tab-selected">ok this is a company</div>
     </div> 
   </div>
</div>

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