本帖最后由 追影 于 2014-7-1 10:14 编辑
dtree是个很不错的无限极客户端分类jquery控件,默认的支持checkbox,但很多时候又要用到 所以给加了复选框 不影响原来控件使用
<script>
t = new dTree('t');
t.add(0,-1,'管理内容权限');
<volist name="type_tree" id="vo">
t.add({$vo.typeid},{$vo.fid},'<input name="typeids[]" type="checkbox" value="{$vo.typeid}" id="l{$vo.typeid}" pId="l{$vo.fid}">{$vo.typename}');
</volist>
document.write(t);
$("input[type='checkbox']").click(function(){
var pId=this.id;
var id = $(this).attr("pId");
//alert(id);
var checked=this.checked;
$("input[id='"+ id +"']").attr("checked",checked);
findparent(id);
findChild(pId);
//选中父节点
function findparent(id){
var children=$("input[id='"+ id +"']").attr("checked",checked);
if(children.length>0){
children.each(function(){
var tid = $(this).attr("pId");
findparent(tid);
});
}
}
//选中子节点
function findChild(pId){
var children=$("input[pId='"+pId+"']").attr("checked",checked);
if(children.length>0){
children.each(function(){
findChild(this.id);
});
}
}
});
</script>
|