简体   繁体   English

dojo.destroy()使节点为空,而不是将其删除

[英]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 在执行remove()之后剩下的部分:这里是完整的源代码: http : //pastebin.com/0YN5TKvG

dojo.destroy is working just fine, you need to examine your DOM more carefully. dojo.destroy运行正常,您需要更仔细地检查DOM。 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. 您正在将“ selectedMail”类添加到td元素, dojo.destroy完全删除了该元素,并且(当然)不考虑父级tr元素。

Instead of 代替

dojo.destroy(selectTag);

You can use dojo.empty 您可以使用dojo.empty

dojo.empty(selectTag);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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