谁能帮我弄清楚为什么这在 Dojo 1.8 中有效但在 1.9 中无效?
在 1.8 中,树被放置在“pilotTreeContainer”内容窗格中。在 1.9 中,如果您在 Firebug 中查看,树就在那里,但在视觉上,它只是显示一个加载图形。在包含此代码的小部件的模板文件中声明了 PilotTreeContainer。所有这些代码都在postCreate
方法中。
var treeStore = lang.clone( store );
var treeModel = new ObjectStoreModel(
{
store: treeStore,
query: { id: 'all' },
mayHaveChildren: function ( item ) // only ships have the unique attribute
{
return item.unique === undefined;
}
} );
var pilotTree = new Tree(
{
model: treeModel, // do we need to clone?
autoExpand: true,
showRoot: false,
title: 'Click to add',
openOnClick: true,
getDomNodeById: function ( id ) // new function to find DOM node
{
if ( this._itemNodesMap !== undefined && this._itemNodesMap[ id ] !== undefined && this._itemNodesMap[ id ][0] !== undefined ) {
return this._itemNodesMap[ id ][0].domNode;
}
else {
return null;
}
}
} );
this.pilotTree = pilotTree;
this.pilotTreeContainer.set( 'content', pilotTree );
我试过在树和内容窗格上调用启动。
调试 dijit/Tree 代码,似乎有一个永远不会解决的延迟。当从 _load 函数调用时(尝试扩展根节点时this._expandNode(rn).then
),它从 _expandNode 函数返回。
在 dijit/Tree 中失败的部分是这样的:
// Load top level children, and if persist==true, all nodes that were previously opened
this._expandNode(rn).then(lang.hitch(this, function(){
// Then, select the nodes specified by params.paths[].
this.rootLoadingIndicator.style.display = "none";
this.expandChildrenDeferred.resolve(true);
}));
为什么树不显示?出了什么问题?