我正在尝试将环绕方面用于expand
aGridX
的树的功能。
简化的代码如下:
var myGrid = ...; // features a tree
var myConditional = ...; // some boolean
dojo.aspect.around(myGrid.tree, "expand", function(original) {
return function(id, skip) {
// TODO check the conditional and decide whether
// to return the deferred function as is, or
// return a function that does nothing but log into the console
var deferred = original(id, skip);
return deferred;
};
});
不幸的是,按原样调用dojo 方面(即没有对我的条件等进行任何检查)是有问题的。
单击 expando 后,控制台中将引发错误:
Uncaught TypeError: t.isExpanded is not a function
...指向 GridX 树模块的expand
原始函数的主体:
var d = new Deferred(), t = this;
if(!t.isExpanded(id) && t.canExpand(id)){ // here
显然,我对 aspect around 如何工作的解释是错误的,并且范围t
成为Window
对象而不是树本身。
我希望有一个我可以使用的快速修复/解决方法?
澄清我的实际目的
在某些情况下,网格底层存储所查询的后端会在短时间内无法访问。事物的实现方式,扩展树的节点将查询后端。在后端不可用的非常短的窗口期间(我可以从前端代码中轻松知道),我想忽略对扩展的点击)。