First the "After request: false" message is printed, then the "On failure: true" but it is late. How can I affectively cancel the drop on ajax failure? Any tips?
I guess I am using asynchronous widgets. I use nodeType: 'async' in my trees, if this is what you are asking. I understand the fact that ajax request is asynchronous, but how can you handle such cases when you want to cancel a drop after an synchronous ajax request?
I would say, return false from onNotifyDrop, cache the drop event, if the ajax event is successful, complete the drop. I've done this before and it works.
I tried to follow your instructions but it didn't work. Maybe I didn't do it properly. When an 'beforenodedrop' event is fired at my tree, the handler -that it is called- does not wait for Ajax to return (either success or failure). When this function returns, game is over (no matter if I cache the event and try to fire the event again or call some other function). Am I missing something here?
You have to forget about the drop doing the business.
record what is being dropped where. CANCEL the drop event.
Then, in your Ajax success handler, perform the removal of the dragged "thing" (was it a treenode, I forgot), and the addition to wherever the drop point was.
Thank you both Jesus and Animal for your help! I think that you -more or less- say the same thing. But you helped me a lot to figure out a solution to this:
I always return true in case of a valid drop. I also cache the drop event and in case of an Ajax failure, I just remove the node that has been dropped (special care needed for the node ids). I could also do it the other way around. Always reject a drop, but in case of an ajax success to add the drop node. It turned out to be easier than I thought...