meteor
meteor

Reputation: 658

dojo.destroy() make node empty, not delete it

i've got a table, where dynamically adding and deleting rows. When i need to remove some element, it's not deleting, it's only make it emty. here's remove function:

        function remove() {
            dojo.forEach(
                dojo.query(".selectedMail"),
                function(selectTag) {
                     dojo.destroy(selectTag);
                }
              );
        }

here's selecting function:

        var myBehavior = {
            ".row": {
                //onclick: dojo.addClass(evt.target, "buttonDown")
                onmousedown: function(evt) {
                    if(dojo.hasClass(evt.target, "selectedMail"))
                        dojo.removeClass(evt.target, "selectedMail");
                    else
                        dojo.addClass(evt.target, "selectedMail");
                }
            }
        };

here's table:

    <table>
        <tbody id="tbody123">
            <tr class="row">
                <td >simplesimplesimplesimplesimple</td>
            </tr>
            <tr class="row">
                <td>simplesimplesimplesimplesimple</td>
            </tr>
            <tr class="row">
                <td>simplesimple</td>
            </tr>
            <tr class="row">
                <td>simple</td>
            </tr>
        </tbody>
    </table>

after remove() executing there remaining: here's full source: http://pastebin.com/0YN5TKvG

Upvotes: 0

Views: 2194

Answers (2)

Ron
Ron

Reputation: 514

Instead of

dojo.destroy(selectTag);

You can use dojo.empty

dojo.empty(selectTag);

Upvotes: 0

Frances McMullin
Frances McMullin

Reputation: 5706

dojo.destroy is working just fine, you need to examine your DOM more carefully. You are adding the class of "selectedMail" to the td element, dojo.destroy is completely removing that element and (of course) leaving the parent tr element alone.

Upvotes: 1

Related Questions