DojoAttachPoint 理解
在 Dojo declaration 和 Dojo template 中,经常见到 dojoAttachPoint="xxx" 这种语句,经过查文档,终于有了些理性的认识。举例说明如下:
|
如果想在 js 中修改 thead 、tr 时,就可以通过 dojoAttachPoint 指定的别名 head , headRow 来引用到 thead , tr ,从而可以操作它。更深层地理解,就是 thead , tr 在页面的 DOM 树上分别对应着 DOM Node ,JS 操作 DOM 树时,要得到 DOM node 的实例时,才能对其进行操作。
比如在上面示例的表格中,要增加一个 td 结点时,就要得到 tr 的 instance,然后对其操作;在 JS 中实现的代码如下:
var tth = document.createElement("th");
this.headRow.appendChild(tth);
或者:
this.headRow.appendChild(document.createElement("td"));
如有误请指出。
阅读(6224) | 评论(0) | 转发(0) |