如何指定jQueryUI Tab目标面板?

发布于 2024-07-23 12:16:27 字数 734 浏览 7 评论 0原文

当所有内容都是通过 AJAX 加载并且目标位于父“选项卡”div 之外时,为 jQueryUI 选项卡指定共享目标面板的最简洁方法是什么?

例如:

<div id="tabs">
  <ul>
    <li><a href="link1.html" title="Go to Link 1"><span>Link 1</span></a></li>
    <li><a href="link2.html" title="Go to Link 2"><span>Link 2</span></a></li>
    <li><a href="link3.html" title="Go to Link 3"><span>Link 3</span></a></li>
    <li><a href="link4.html" title="Go to Link 4"><span>Link 4</span></a></li>
  </ul>
</div>

<div id="panel">Content should be loaded here.</div>

编辑:我希望每个链接都有一个唯一的标题属性

Whats the cleanest way to specify a shared target panel for jQueryUI tabs when all the content is loaded via AJAX and the target lies outside of the parent "tabs" div?

For example:

<div id="tabs">
  <ul>
    <li><a href="link1.html" title="Go to Link 1"><span>Link 1</span></a></li>
    <li><a href="link2.html" title="Go to Link 2"><span>Link 2</span></a></li>
    <li><a href="link3.html" title="Go to Link 3"><span>Link 3</span></a></li>
    <li><a href="link4.html" title="Go to Link 4"><span>Link 4</span></a></li>
  </ul>
</div>

<div id="panel">Content should be loaded here.</div>

EDIT: I would prefer to have a unique title attribute per link

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

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

发布评论

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

评论(3

枉心 2024-07-30 12:16:27

使用 li 标签上的 aria-controls 属性来选择面板的 id

<div id="tabs">
   <ul>
     <li aria-controls="panel"><a href="link1.html"><span>Link 1</span></a></li>
     <li aria-controls="panel"><a href="link2.html"><span>Link 2</span></a></li>
     <li aria-controls="panel"><a href="link3.html"><span>Link 3</span></a></li>
     <li aria-controls="panel"><a href="link4.html"><span>Link 4</span></a></li>
   </ul>
  <div id="panel" >Content should be loaded here.</div>
</div>

Use aria-controls attribute on li tag to select the id of panel

<div id="tabs">
   <ul>
     <li aria-controls="panel"><a href="link1.html"><span>Link 1</span></a></li>
     <li aria-controls="panel"><a href="link2.html"><span>Link 2</span></a></li>
     <li aria-controls="panel"><a href="link3.html"><span>Link 3</span></a></li>
     <li aria-controls="panel"><a href="link4.html"><span>Link 4</span></a></li>
   </ul>
  <div id="panel" >Content should be loaded here.</div>
</div>
甜中书 2024-07-30 12:16:27

为您的目标 div 指定一个标题,例如:

<div id="panel" title="contentPane">Content should be loaded here.</div>

并为您的选项卡链接指定相同的标题:

<div id="tabs">
  <ul>
    <li><a href="link1.html" title="contentPane"><span>Link 1</span></a></li>
    <li><a href="link2.html" title="contentPane"><span>Link 2</span></a></li>
    <li><a href="link3.html" title="contentPane"><span>Link 3</span></a></li>
    <li><a href="link4.html" title="contentPane"><span>Link 4</span></a></li>
  </ul>
</div>

Give your target div a title, e.g.:

<div id="panel" title="contentPane">Content should be loaded here.</div>

and give your tab links the same title:

<div id="tabs">
  <ul>
    <li><a href="link1.html" title="contentPane"><span>Link 1</span></a></li>
    <li><a href="link2.html" title="contentPane"><span>Link 2</span></a></li>
    <li><a href="link3.html" title="contentPane"><span>Link 3</span></a></li>
    <li><a href="link4.html" title="contentPane"><span>Link 4</span></a></li>
  </ul>
</div>
阳光下慵懒的猫 2024-07-30 12:16:27

看来,在当前版本的 jQueryUI (1.7.2) 中,如果不修改事件,这是不可能的。

我已提交补丁以考虑更优雅的解决方案。

It appears this is not possible with the current release of jQueryUI (1.7.2) without event modification.

I have submitted a patch for consideration for a more graceful solution.

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