I have played around with this, and I discovered that the "accept" property appears to not be an Array as the dojo manual suggests. It shows as some kind of Object (Other than an Array) in chrome's debugger with an attribute called "text" set to a value of 1 by default. Accessing as element.accept = "";
to disable it works, but after that there is no going back to enabling it again using the same method and trying something like element.accept = ['text'];
I also tried accessing it by element.accept.text
and this didn't seem to work either once the object was instantiated.
For my application, I needed to allow a single item to be in each td in a table, and I used the following function to do this and preserve the order of the items in the table using a variant of the one listed here. I thought it was worth mentioning.
function changeAccept(source)
{
var element = document.getElementById(source.node.id);
console.log("element:"+element);
var element_father = element.parentNode;
var td = document.createElement("td");
td.setAttribute('id',element.id);
element_father.replaceChild(td,element);
var newsource = new dojo.dnd.Source(element.id, {accept: ['text']});
dojo.connect(newsource, "onDrop", function(source, nodes, copy) {
console.log("Dropped", newsource, source, nodes, copy);
newsource.accept = "";
changeAccept(source);
});
return newsource;
}
var priorelement = new dojo.dnd.Source(element.id, {accept: ''}); //disabled
changeAccept(priorelement); //enabled and in same position in table