when using insertNodes a unique id will be created for the nodes.
insertNodes(addSelected, data, before, anchor)
How do we assign a certain name / text as an id for the new nodes?
when using insertNodes a unique id will be created for the nodes.
insertNodes(addSelected, data, before, anchor)
How do we assign a certain name / text as an id for the new nodes?
Create a custom "creator" function, and set the id on the item. Example :
In your html
<ol id="listNode">
</ol>
In your javascript :
require(["dojo/dnd/Source"]);
function myCreator( item, hint ) {
var myLi = dojo.create( 'li', { id : item.id, innerHTML: item.text });
if (hint == 'avatar') {
// create your avatar if you want
myLi.innerHTML = "Moving " + item.text + "...";
}
return {node: myLi, data: item, type: "foo"};
}
dojo.ready(function() {
var list = new dojo.dnd.Source("listNode", {creator: myCreator});
list.insertNodes(false, [
{ id : "id1", text : "foo"},
{ id : "id2", text : "bar"},
{ id : "id3", text : "baz"}
]);
});