简体   繁体   中英

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 link 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);
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM