php代码
$Area = new AreaModel();
$area = $Area->getList();
foreach ($area as $key => $val) {
$area[$key]['url'] = U('setting/customer', array('area_id' => $val['id']));
}
$area_list = Tree::many($area);
$this->assign('manyList', json_encode($area_list));
*******************************************************************************************
html代码
<script src="__LIB__/bootbox/bootbox.js" type="text/javascript"></script>
<ul class="tree tree-lines" id="areaTree"></ul>
<script type="text/javascript">
$('#areaTree').tree({
data: {$manyList},
initialState: 'expand',
itemCreator: function ($li, item) {
if (item.children.length > 0) {
$li.text(item.name);
} else {
$li.append($('<a/>', {href: item.url}).text(item.name));
}
}
});
</script>