[Proto-Scripty] Re: Drag and Drop with conditional revert

2009-03-05 Thread david

Hi ColinFine,

I think that the method that will hide the element during request is
as you say BAD :((
I will do another way:
- if dropsite is good, just lauch AJAX request, but before set a
spinner inside, near, where you want to indicate that actually the
apply is processing something.
- If response is not good, just do a manual revert (I did not think
you could have bundle callback, ... to do this.

But, The idea of making all info available in the CLIENT is THE GOOD
idea, because each time you go and check if element could be dropped,
you make one more call to the server and it should create all
necessary process to respond to the request == which consume a lot of
resources.

--
david

On 25 fév, 20:41, ColinFine colin.f...@pace.com wrote:
 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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: Drag and Drop with conditional revert

2009-03-05 Thread ColinFine



On Mar 5, 12:30 pm, david david.brill...@gmail.com wrote:
 Hi ColinFine,

Thanks for replying.

 I think that the method that will hide the element during request is
 as you say BAD :((
Yes
 I will do another way:
 - if dropsite is good, just lauch AJAX request, but before set a
 spinner inside, near, where you want to indicate that actually the
 apply is processing something.
Not relevant - I will do that if I think it needs it
 - If response is not good, just do a manual revert (I did not think
 you could have bundle callback, ... to do this.

That is really what I was asking for. I am surprised both that I can't
do it through a callback, and that Draggable does not provide me a
callable method to do it.

 But, The idea of making all info available in the CLIENT is THE GOOD
 idea, because each time you go and check if element could be dropped,
 you make one more call to the server and it should create all
 necessary process to respond to the request == which consume a lot of
 resources.

I see that point, and I have sometimes done it that way, but there are
two reasons against it:
1. All the data that may be required to perform any of the validations
needs to be downloaded with the original page load.
2. The validation has to be coded in Javascript, but is likely to
duplicate some code which is also needed in the server program (PHP in
my case).

For a given site, there will be a trade-off between these different
points, and you make a decision depending on the amount of data
required, the likely number of drag-drop operations, the speed of
connection, the load on the server etc.

Colin

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---