如何在jQuery Treeview插件之外创建全部展开和折叠所有链接? [英] How Do I Create Expand All and Collapse All Links Outside of the jQuery Treeview Plugin?
问题描述
jQuery Treeview插件添加了全部折叠,全部展开和切换如下定义控件属性时,所有指向"treeviewcontrol" div的链接:
The jQuery Treeview Plugin adds Collapse All, Expand All and Toggle All links to the "treeviewcontrol" div when the control property is defined as follows:
$("#black, #gray").treeview({
control: "#treecontrol",
persist: "cookie",
cookieId: "treeview-black"
});
这很好用,但是我希望能够从树视图本身之外的其他页面元素扩展和折叠树视图.我已经查看了来源,但无法弄清楚.
This works great, but I'd like the ability to expand and collapse the treeview from other page elements outside of the treeview itself. I've looked at the source, but I can't figure it out.
推荐答案
如果您在此处查看演示页面,则可以看到存在div#treecontrol,只需将其设为treecontrol
类即可:
If you check out the demo page here you can see there is a div#treecontrol, well just make it a treecontrol
class:
<div class="treecontrol">
<a title="Collapse the entire tree below" href="#"><img src="../images/minus.gif" /> Collapse All</a>
<a title="Expand the entire tree below" href="#"><img src="../images/plus.gif" /> Expand All</a>
<a title="Toggle the tree below, opening closed branches, closing open branches" href="#">Toggle All</a>
</div>
然后,您可以制作此控件的尽可能多的副本,并将它们放置在所需的任何位置.不要忘记修改控制参数:
Then you can make as many copies of this control and put them anywhere you want. Don't forget to modify the control parameter:
$("#tree").treeview({ control: ".treecontrol" })
这篇关于如何在jQuery Treeview插件之外创建全部展开和折叠所有链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!