Site Navigation

Jan 22, 2009

T is Undefined - Dojo DND (Drag N Drop)

Here is another note, that will hopefully help some other poor developer that runs into the same problem. I'm implementing Dojo drag and drop for a project. I'm refactoring the code so that a table is created from an Ajax call as opposed to a static data. When the table data is static and my table container has a static dojoType of dojo.dnd.source, everything works fine. However, as soon as you add dynamic data to the table, drop stops working. A javascript error "T is undefined" is generated and that is that.

The problem is cause by the fact that the dojo dnd code does not check the container for updates. Consequently, when it finds new data in there, breakage occurs.

The solution is to create your table first. Then, add the dnd features to the table programattically. For example:

dndTable = new dojo.dnd.Source(dojo.byId("idOfTargetContainer"));

Voila! Dnd functionality is added and nothing breaks. I still have a few table manipulation features. So if I run across any other tips, I'll be sure to share.

Post a Comment

Favorite Links Feed