tags:

views:

715

answers:

3

I've got two dojo.dnd.Sources with items. Whenever an item is dropped I need to persist the new order of the items in the Sources using an xhr.

Is there an dojo event or topic that is fired after an dnd operation has (successfully) finished? What would be the best way to use it?

A: 

I couldnt comment because I lack the reputation .. but have you tried the forum on the dojo site? Ive posted there before and received good feedback.

Matt1776
*sigh* they are killing off the dojo forums. http://dojotoolkit.org/forum/dojo-core-dojo-0-9/dojo-core-support/forum-deprecation-warning
seth
!!! I sadly stand corrected. Thanks for the heads up.
Matt1776
+1  A: 

You can use dojo.subscribe to do something when a drop is finished like so:

dojo.subscribe("/dnd/drop", function(source, nodes, copy, target) {
  // do your magic here
});

There's examples of using subscribe on the dojotoolkit tests site. More info about dojo publish and subscribe too.

Alternately, you could connect to the onDndDrop method.

var source = new dojo.dnd.Source( ... );
dojo.connect( source, "onDndDrop", function( source, nodes, copy, target ) {
  // make magic happen here
});

connect methods are called at the end so the items will be there at that point.

seth
The dropped element does has not yet arrived if I use "/dnd/drop". Its still at the source. I found some magic to do what I want using setTimeout.
Wienczny
+2  A: 
Eugene Lazutkin