tags:

views:

221

answers:

1

I use Dojo 1.3.1, essentially under FF3.5 for now.

I have a dnd source which is also a target. I programmatically add some nodes inside, by cloning template items. The aim for the user is then to use dnd to order the items. It is ok for one or two actions, then I got the "this.manager.nodes[i] is null" error in Firebug, then no more dnd action is taken into account.

My HTML (jsp), partial:

<div id="templates" style="display:none">
<div class="dojoDndItem action" id="${act.name}Template">
<fieldset>
  <legend class="dojoDndHandle" >${act.name}</legend>
  <input id="${act.name}.${parm.code}." type="text" style="${parm.style}"
    dojoTypeMod="dijit.form.ValidationTextBox"
    /><br>
</fieldset></div>
</div>

My Javascript for adding/removing dnd items nodes, partial :

function addActionFromTemplate(/* String */actionToCreate, /* Object */data) {
    // value of actionToCreate is template id
    var node = dojo.byId(actionToCreate + "Template");
    if (node) {
     var actNode = node.cloneNode(true);

     // make template id unique
     actNode.id = dojo.dnd.getUniqueId();

     // rename inputs (add the action nb at the end of id)
     // and position dojo type (avoid double parsing)
     dojo.query("input[type=text], select", actNode).forEach( function(input) {
      input.id = input.id + actionsCount;
      dojo.attr(input, "name", input.id);
      dojo.attr(input, "dojoType", dojo.attr(input, "dojoTypeMod"));
      dojo.removeAttr(input, "dojoTypeMod");
     });

     // insert the action at script's tail
     actionList.insertNodes(true, [ actNode ]);

     dojo.parser.parse(actNode);

     // prepare for next add
     actionsCount++;
    }
}

function deleteAction(node) {
    var cont = getContainerClass(node, "action");
    // remove the fieldset action
    cont.parentNode.removeChild(cont);
}

Thanks for help ...

A: 

OK, it seems that, finally, simply using :

actionList.insertNodes(false, [ actNode  ]);

instead of

actionList.insertNodes(true, [ actNode  ]);

fixed the pb .