2009-07-20 29 views
0

我使用Dojo 1.3.1,現在基本上在FF3.5下。拖動dnd項目生成「this.manager.nodes [i]爲空」

我有一個dnd源也是一個目標。我編程添加一些節點,通過克隆模板項。然後用戶的目標是使用dnd來訂購物品。對於一兩個動作是可以的,然後我在Firebug中得到了「this.manager.nodes [i]爲null」的錯誤,那麼就不會考慮更多的dnd動作。

我的HTML(JSP),部分:

<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> 

我的JavaScript添加/刪除DND項目節點,部分:

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

感謝您的幫助......

+0

你看起來沒問題。添加/刪除項目後,您是否在dojo.dnd.Source上調用sync()?你可以發佈你的源代碼的HTML嗎? – seth 2009-07-20 16:18:23

回答

0

好吧,看來,最後,簡單地使用:

actionList.insertNodes(false, [ actNode ]); 

代替

actionList.insertNodes(true, [ actNode ]); 

固定的PB。