Login Register

How to access data in items in a dnd container?

My dojo.dnd.Source cart has items in it. Each item has data associated with it. We know this because the creator can access data.name, data.price, etc.

When a new item is dropped onto cart, I want to update a "Your total is" display, by adding up data.price of all the items in the cart.

But cart.getAllNodes() returns an array of HTMLDivElement and the data isn't accessible.

How do I access the data in each item in a dojo.dnd.Source?

Solved

// Read name from the HTMLDivElement.
// Then read dndItem from the Container, by name.
var item = cart.getItem(cartItems[0].id);

// Now access data inside dvdItem.
console.debug("Item "+i+":"+item.data.name+" price:"+item.data.price);