Login Register

dndItem value changes out from under me.

When a second copy of an item is dropped onto my cart, I bump the count on the previous item and delete the new item. The code that computes the cost of the cart then sees one item with a count of 2.

When another copy is dropped, the count on the item already in the cart is back to 1.

Any idea why?

The function in question is longer than the forum allows. The full description is at http://kevinkoch.com/dojo.dnd-question.txt.

You do some wrong

You do some wrong assumptions in your code. For example, you assume that onDndDrop() is called when this source/target is dropped on. Actually onDndDrop() is a subscriber to the topic "/dnd/drop". It means that when drop is detected all subscribers (== all onDndDrop() methods of all sources) will be called. You have to check if this drop is actually relevant to your source.

Take a look at http://www.sitepen.com/blog/2008/06/10/dojo-drag-and-drop-1/ — it may give you some ideas on how to implement what you want.