Dave Stewart
2007-Aug-15 11:51 UTC
How would I change the drop behavior of a sortable''s draggable?
Specifically, if I drop a draggable on a droppable, but I decide that it can''t be droopped there, how do I make it go to another droppable instead? Can I just fire another method? Thanks, Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ken Snyder
2007-Aug-15 16:12 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
Dave Stewart wrote:> Specifically, if I drop a draggable on a droppable, but I decide that > it can''t be droopped there, how do I make it go to another droppable > instead? > > Can I just fire another method? > > Thanks, > Dave > >What do you mean by "decide"? You should constrain which elements droppables can receive ahead of time by listing the acceptable css classes in the "accept" option. It seems like strange behavior to have a draggable go somewhere that the user didn''t drag it. Maybe you can explain. - Ken Snyder --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Stewart
2007-Aug-15 19:24 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
Hi Ken, Thanks for your reply, and sorry for being a bit vague. I think I understand what you are suggesting with the accept option (from what I''ve seen in the docs) and I think that may be what I want. I''ll look into it and will report back.. With regards to my other point - I''ll try and explain. What I want to do is replicate the behavior that a drop action fires - ie animating to a the last sortable''s child node - however, I''d like to be able to specify the sortable it goes to. At the moment I''m hacking it using cloned nodes and Effect.Move and Position.cumulativeOffset() to give me something like that behaviour - but it''s awfully hacky. An example of WHY I want to do this might be: Lets say you have several sortables (1 source, and several targets), but you decide to remove one of the targets that contains draggables. These draggables would need to animate smoothly back to the "source" so they coudl be re-dropped on other targets. Does that make sense? Cheers, Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ken Snyder
2007-Aug-15 19:53 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
Dave Stewart wrote:> ... > > What I want to do is replicate the behavior that a drop action fires - > ie animating to a the last sortable''s child node - however, I''d like > to be able to specify the sortable it goes to. >I''m not sure how this would be done. Perhaps someone else knows or you could look into the sortables code.> ... > Lets say you have several sortables (1 source, and several targets), > but you decide to remove one of the targets that contains draggables. > These draggables would need to animate smoothly back to the "source" > so they coudl be re-dropped on other targets. > ... >My thought would be to capture the initial position of all the source draggables then just move them back if their parent needed to be removed. This would probably be outside of the Draggable functionality. That certainly would be a pretty cool effect. - Ken --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Stewart
2007-Aug-15 21:13 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
I''ve taken a look at the source code and whilst I understand some of it, there''s a lot that goes over my head. I can hack around and sometimes make things happen, but as I said - it''s mainly hacking. Fingers crossed that someone else chips in... (What we need is documentation to the same standard as Prototype''s really. The Wiki is a little thin...) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Tom Gregory
2007-Aug-15 22:02 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
On Aug 15, 2007, at 3:13 PM, Dave Stewart wrote:> (What we need is documentation to the same standard as Prototype''s > really. The Wiki is a little thin...)Look on the bright side: it''s a wiki! =) Once you do figure it out, make sure to add it. Christophe''s new Prototype/Scriptaculous book at Pragmatic Programmers is pretty good too. TAG --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Stewart
2007-Aug-16 11:38 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
Hi Tom,> Look on the bright side: it''s a wiki! =) > Once you do figure it out, make sure to add it.Of course, anything I discover I will attempt to add. However, I find the wiki a confusing and badly-formatted place. Arg. Just downloaded Christophe''s book ... hopefully that will give me some more info! Cheers, Dave --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Gareth Evans
2007-Aug-16 22:07 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
The way I did this was to store a custom attribute against each droppable that was updated onDrop (ie from an event handler) This contained the ID of the ''last known valid location''. Then, onDrop, I performed my validity checks (in my case it was a calendar so I was making sure the appointment didnt overlap with any others) and if it was invalid, I got the current position from the object and found the ''last known valid location'' position, calculated the move distances (x&y) and then called an adapted version of the code from the revert function from inside dragdrop.js. Good luck Gareth On 8/16/07, Dave Stewart <singalongwithdave-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > > Hi Tom, > > > Look on the bright side: it''s a wiki! =) > > Once you do figure it out, make sure to add it. > > Of course, anything I discover I will attempt to add. However, I find > the wiki a confusing and badly-formatted place. Arg. > > Just downloaded Christophe''s book ... hopefully that will give me some > more info! > > Cheers, > Dave > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Stewart
2007-Aug-17 12:24 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
Hi Gareth, Thanks for chipping in! This sounds like we are doing very similar things. In my case I''m going to have a confirm box saying "Are you sure you want to drag this item here?", and if not I''ll move the item back. I assume the reverteffect mothod is what you''re talking about? function(element, top_offset, left_offset) { var dur Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, queue: {scope:''_draggable'', position:''end''}}); } I''m doing pretty much the same thing at the moment, but what I can''t fire out is how to intercept the automatic behaviour when the draggable is dropped. Any ideas on how to do that? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Gareth Evans
2007-Aug-18 00:20 UTC
Re: How would I change the drop behavior of a sortable''s draggable?
You need to observe the onDrop event on either the draggable or the droppable. I cant recall which I used. For usability though, the messagebox kinda breaks the flow. You could instead put an ''undo'' similar to how google does it at the top of the item that creates the move, that way you dont get the nasty popup, and you can style it. Gareth On 8/18/07, Dave Stewart <singalongwithdave-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > > Hi Gareth, > Thanks for chipping in! > > This sounds like we are doing very similar things. In my case I''m > going to have a confirm box saying "Are you sure you want to drag this > item here?", and if not I''ll move the item back. > > I assume the reverteffect mothod is what you''re talking about? > > function(element, top_offset, left_offset) { > var dur > Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; > new Effect.Move(element, { x: -left_offset, y: -top_offset, > duration: > dur, queue: {scope:''_draggable'', position:''end''}}); > } > > I''m doing pretty much the same thing at the moment, but what I can''t > fire out is how to intercept the automatic behaviour when the > draggable is dropped. > > Any ideas on how to do that? > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---