Chinaunix首页 | 论坛 | 博客
  • 博客访问: 240823
  • 博文数量: 29
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 715
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-23 23:55
文章分类

全部博文(29)

文章存档

2009年(7)

2008年(22)

我的朋友

分类:

2008-03-11 22:41:40

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) |
给主人留下些什么吧!~~