Kill a node in dojo.dnd.source ?

Posted by Soulhuntre on Stack Overflow See other posts from Stack Overflow or by Soulhuntre
Published on 2010-06-10T07:47:18Z Indexed on 2010/06/10 7:52 UTC
Read the original article Hit count: 523

Filed under:
|
|

Related to my SO issue at http://stackoverflow.com/questions/3010996/dojo-extending-dojo-dnd-source-move-not-happening-ideas/3012518#3012518 I am now almost done.

I have a dnd.Source derived class - we can consider it a dnd.Source for now, that has within it a node that has a specific class.

    function declare_mockupSmartDndUl(){
    dojo.require("dojo.dnd.Source");
    dojo.provide("mockup.SmartDndUl");
    dojo.declare("mockup.SmartDndUl", dojo.dnd.Source, {
        markupFactory: function(params, node){
            //params._skipStartup = true;
            return new mockup.SmartDndUl(node, params);
        },
        onDropExternal: function(source, nodes, copy){
            console.debug('onDropExternal called...');  

            // dojo.destroy(this.getAllNodes().query(".dndInstructions"));
            this.inherited(arguments);

            var x = source.getAllNodes().length;
            if( x == 0 ){
                newnode = document.createElement('li');
                newnode.innerHTML = "Hello!";
                dojo.addClass(newnode,"dndInstructions");
                source.node.appendChild(newnode);
            }

            return true;
            // return dojo.dnd.Source.prototype.onDropExternal.call(this, source, nodes, copy);
        }   
    });
}

You can see the place I mean from the dojo.destroy that is commented out because it was totally n00b :)

If I do this var y = this.getAllNodes().query(".dndInstructions") the nodelist in y absolutely does contain the node.

Now I need t kill it, nuke it - get it out of there. Out of the dnd.Source, out of the DOM... gone.

Any ideas how to do it safely? It will be the ONLY node in the list at the time we do whatever it is we are goign to do to kill the thing.

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dojo