I've been struggling to achieve something with drag and drop. I've found a solution, but I don't think it's very elegant, and I was wondering if anybody has a better solution.
I'm dragging an object from one box to another. If it is a suitable dropsite, it fires off an Ajax request to update the database and several parts of the display (including the dropsite). But it is possible that the operation will not be permitted, in which case the Ajax returns a failure code and a message, and the object hasn't been moved in the database. So far so good. But I want the drag to revert not only if the user doesn't find a suitable dropsite, but also if the Ajax operation returns failure. On the other hand, if the Ajax operation succeeds, I don't want it to revert. (It will only be for a moment before the box is redrawn, but it doesn't look good). The workround I've implemented is to hide the element before issuing the Ajax call, and show it again in the failure callback, but not in the success one; so the user won't see it reverting in the latter case. But it means the object you've moved disappears for a moment, which is not very good. Is there a better solution? I wondered if there was a way to use a function in the 'revert' option of the Draggable, or to use the onEnd of the Draggable or onDrop of the Droppable. But none of these have access to the Draggable, only to the dragged element, so I would have to write my own revert. In any case, there doesn't seem to be a callable default 'revert' function in Draggable: I would expect there to be one, so that you can provide a callback which does some other processing and then calls the default. I see that there was a discussion on similar lines last September, but the recommendation there seemed to be to do the checking client-side. That is possible, but would mean that much more data would need to be downloaded, so I prefer to do it on the server. Any suggestions? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---