分享一些关于KnockOut的语法,绑定Tree

<ul class="ak-ps-tree-conul">
<!-- ko foreach:$root.List-->
<!-- ko if:1==1 -->
<li class="pstree-node pstree-closed">
<!-- ko if:ChildItem().length>
0 -->
<i class="ps-treeicon" data-bind="click: OpenThisNode"></i>
<!-- /ko -->
<!-- ko if:ChildItem().length==0 -->
<i class="ps-treeicon empty"></i>
<!-- /ko -->
<a href="javascript:void(0)" class="pstree-anchor" data-bind="text: Name,click:clickThisData"></a>
<!-- ko if:ChildItem().length>
0 -->
<!-- ko template: { name: 'Template', foreach: ChildItem } -->
<!-- /ko -->
<!-- /ko -->
</li>
<!-- /ko -->
<!-- /ko -->
</ul>

<script type="text/html" id="Template">
<ul class="pstree-children">
<li class="pstree-node pstree-closed">
<!-- ko if:ChildItem().length>0 -->
<i class="ps-treeicon" data-bind="click: OpenThisNode"></i>
<!-- /ko -->
<!-- ko if:ChildItem().length==0 -->
<i class="ps-treeicon empty"></i>
<!-- /ko -->
<a href="javascript:void(0)" class="pstree-anchor" data-bind="text: Name,click:clickThisData"></a>
<!-- ko if:ChildItem().length>0 -->
<!-- ko template: { name: 'Template', foreach: ChildItem } -->
<!-- /ko -->
<!-- /ko -->
</li>
</ul>
</script>

 

posted @ 2016-06-14 14:40  Thread-1  阅读(177)  评论(0编辑  收藏  举报