jQuery 选项卡 - 选择创建内容面板的位置
我想知道是否可以在指定位置动态创建选项卡面板?
目前,我的选项卡是通过加载一些 json 动态创建的。我的 div 结构如下所示:
<div id="tabs">
<ul id="tablist"></ul>
</div>
然后它会动态填充类似于下面的结构...
<div id="tabs">
<ul id="tablist">
<li><a href="#panel1">blah1</a></li>
<li><a href="#panel2">blah2</a></li>
<li><a href="#panel3">blah3</a></li>
</ul>
<div id="panel1">Some content...</div>
<div id="panel2">Some content...</div>
<div id="panel3">Some content...</div>
</div>
我想告诉 jQuery 在我选择的父 div 中创建面板 div,例如“#panels”:
<div id="tabs">
<ul id="tablist"></ul>
</div>
<div id="panels"></div>
这可能吗?谢谢。
仅供参考,我没有使用通用的 ui 选项卡外观和样式。感觉,因此不受任何容器设计的束缚。
I'm wondering if it possible to dynamically create the tab panels in a specified location?
At the moment my tabs are dynamically created through loading some json. My div structure is like so:
<div id="tabs">
<ul id="tablist"></ul>
</div>
It then populates the structure dynamically similar to below...
<div id="tabs">
<ul id="tablist">
<li><a href="#panel1">blah1</a></li>
<li><a href="#panel2">blah2</a></li>
<li><a href="#panel3">blah3</a></li>
</ul>
<div id="panel1">Some content...</div>
<div id="panel2">Some content...</div>
<div id="panel3">Some content...</div>
</div>
I would like to tell jQuery to create the panel divs in a parent div of my choice, Eg '#panels':
<div id="tabs">
<ul id="tablist"></ul>
</div>
<div id="panels"></div>
Is this possible? Thanks.
FYI I'm not using the generic ui tab look & feel, so not bound by any container design.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不容易(我可以看到)。
如果您确实想要,您可以通过
或者,您可以采取“其他方式”并通过
请注意,jQuery UI 选项卡 API 目前正在进行重新设计。有一个 pre-alpha 里程碑 可用,并要求他们发表评论。请求将此作为一项功能并看看他们怎么说当然不会有什么坏处。 (如果不出意外的话,他们可能有比上面更好的想法。)
Not easily (that I can see).
You could, if you really wanted, get a similar behavior by
Alternatively, you could go the "other way" and get similar behavior by
As a note, the jQuery UI tabs API is currently undergoing a redesign. There's a pre-alpha milestone available and they're requested comments. It certainly wouldn't hurt to request this as a feature and see what they say. (If nothing else, they may have a better idea than the above.)