开发者

How to add click event to table row using Dojo

I have a table like this:

<table class="thisTable">
    <tr>
        <td class="firstColumn"><a href="somepage.html">First</a></td>
        <td>Apple</td>
        <td>Ant</td>
    </tr>
    <tr>
        <td class="firstColumn"><a href="somepage2.html">Second</a></td>
        <td>Banana</td>
        <td>Bear</td>
    </tr>
    <tr>
        <td class="firstColumn"><a href="somepage3.html">Third</a></td>
        <td>Citrus</td>
        <td>Cat</td>
    </tr>
</table>

What I wanted to do is to be able to click the li开发者_运维百科nk in td.firstColumn even if I click on the other cells in the same row. How do I do this in Dojo? Thanks a lot!


Give the rows a unique class name, then query the domNode and add connect's to them with a loop.

var that = this;
dojo.query('rowClass', this.domNode).forEach(function (node, index, arr) {
    dojo.connect(node, "onclick", function (evt) {
        that.handleEvent(evt);
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜