AUI TreeView 在渲染后执行代码
AUI TreeView execute code after render
渲染树视图后,我想执行一些代码。但只有在渲染完成之后。似乎 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);
有一个名为 "render"
的事件
new Y.TreeView({
boundingBox: '#fruits',
children: [...],
on: {
render: function(){/*Your code here*/}
}
}).render();
渲染树视图后,我想执行一些代码。但只有在渲染完成之后。似乎 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);
有一个名为 "render"
的事件new Y.TreeView({
boundingBox: '#fruits',
children: [...],
on: {
render: function(){/*Your code here*/}
}
}).render();