无法让 jquery 选项卡嵌套 [英] Unable to get jquery tabs nested

查看:20
本文介绍了无法让 jquery 选项卡嵌套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我已经尝试过人们建议内部选项卡也应该通过 jQuery 进行标签化的方法,但是

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

  • it doesn't work
  • all the examples I have seen e.g. http://cse-mjmcl.cse.bris.ac.uk/blog/jQueryNestedMenus/nested.html use topmost div for jQuery tabs call.

代码:

<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>

推荐答案

我在 jquery 论坛和 得到了答案.

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

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

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> 

这篇关于无法让 jquery 选项卡嵌套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆