Ok, I have a set of draggables inside a container div, which is a drop zone for the draggables. The draggables work just fine, until the container div is updated using Ajax.updater (caused by dropping one of the draggables). The only way to get the draggables to work again is to refresh the page. my draggables look like this: <div id="drag-1" class="dragger" style="top:10px;left:30px;width:60px;height:60px;"> <img src="/path/to/image/file" alt="title" /> </div> <script type="text/javascript" charset="utf-8" language="javascript"> // <![CDATA[ new Draggable("drag-1",{ snap: function(x,y,draggable){ function constrain(n,lower,upper){ if(n > upper) return upper; else if(n < lower) return lower; else return n; } element_dimensions = Element.getDimensions(draggable.element); parent_dimensions Element.getDimensions(draggable.element.parentNode); return[ constrain(x, 8, parent_dimensions.width - element_dimensions.width - 8), constrain(y, 8, parent_dimensions.height - element_dimensions.height - 8)]; } }); // ]]> </script> The Ajax.updater returns the same code. Does any one have any clue why the draggables would quit after the update? Would more information be helpful? I''ve tested this in firefox 1.6 on winxp/mac osx, safari, and ie6. Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Oct-25 06:17 UTC
Re: draggables quit working after Ajax.updater
naryga a écrit :> Ok, I have a set of draggables inside a container div, which is a drop > zone for the draggables. The draggables work just fine, until the > container div is updated using Ajax.updater (caused by dropping one of > the draggables). The only way to get the draggables to work again is > to refresh the page.That''s nominal. You should manually *unregister* any Droppable before removing it from the DOM. This is explicitly stated (although admittedly rather down the page) in the wiki: http://wiki.script.aculo.us/scriptaculous/show/Droppables.add ''HTH -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Oct 25, 1:17 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:>That''s nominal. You should manually *unregister* any Droppable before > removing it from the DOM. This is explicitly stated (although > admittedly rather down the page) in the wiki: > > http://wiki.script.aculo.us/scriptaculous/show/Droppables.addMaybe I just didn''t understand. My situation is that I have several draggable divs sitting in a parent div that I have used Droppable.add to make droppable. When any of the draggable divs is dragged, then dropped on the parent div, the droppable parent div calls Ajax.updater, which, basically, checks that none of the draggable items are overlapping, saves the new positions to a database then updates the parent div (in case the draggables do overlap, it sends the recently moved one back to it''s origional position). I don''t see how this is removing the droppable div from the dom... But like I said, I could have easily have missunderstood. My grasp of the finer points of javascript and the dom are sketchy at best! Given the situation above, do I need to unregister the droppable? If so, when would I do it, consider the droppable in question is causing the Ajax.updater call that causes it to be removed? Or am I going about this the complete wrong way? thanks again! Nathan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2006-Oct-26 06:30 UTC
Re: draggables quit working after Ajax.updater
naryga a écrit :> moved one back to it''s origional position). I don''t see how this is > removing the droppable div from the dom... But like I said, I couldApparently, there''s no removal indeed. However, if I get you right, you update the parent div just in case there was some overlapping? I guess the best way would be to prevent drop if there is overlapping, checking earlier on. You could implement that by using the snap callback function, for instance. It''s normally used to make the moves "stick to grid", or contain them within visual boundaries. It could very well be used to make moves "stick outside existing items", for instance. This way, you''d be sure that a dropped component is indeed not overlapping! -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---