AUI TreeView在渲染后执行代码

时间:2015-02-17 08:21:51

标签: treeview liferay-aui

在渲染树视图后,我想执行一些代码。但只有在渲染完成之后。似乎AUI异步呈现树的节点。在render()之后是否有事件或参数来运行函数? 这让我觉得TreeView被绘制为异步。

var render = new Y.TreeView(
          {
            boundingBox: '#fruits',             
            children: [              
              {
                children: [
                  {label: 'Watermelon', leaf: true},
                  {label: 'Apricot', leaf: true},                     
                  {
                        children: [
                          {label: 'Watermelon', leaf: true},
                          {label: 'Apricot', leaf: true},                             
                          {
                                children: [
                                  {label: 'Watermelon', leaf: true},
                                  {label: 'Apricot', leaf: true},                                     
                                  {label: 'Pomegranate', leaf: true}
                                ],
                                expanded: true,
                                label: 'second branch',
                                type: 'task'
                              }
                        ],
                        expanded: true,
                        label: 'second branch'
                      }
                ],
                expanded: true,
                label: 'first branch'
              },
              {
                children: [
                  {label: 'Watermelon', leaf: true},
                  {label: 'Apricot', leaf: true}                     
                ],
                expanded: true,
                label: 'second branch'
              }
            ]
          }
        ).render();

        var lis = Y.all('.tree-node');
        console.log(lis); // 2 items here

        setTimeout(function(){

            var lis = Y.all('.tree-node');
            console.log(lis);// 28 here
        }, 1000);

1 个答案:

答案 0 :(得分:0)

有一个名为“render”的事件

new Y.TreeView({
        boundingBox: '#fruits',             
        children: [...],
        on: {
            render: function(){/*Your code here*/}
        }
}).render();