Hello all, I want to extend a draggable object so it has one more attribute (type attribute, so I can distinguish different draggable types). Can anyone tell me how to do it? I''ve search throught the examples (like http://wiki.script.aculo.us/scriptaculous/show/ExtendClass) but I can''t seem to understand what I should do. Thanks for you help, H
Instead of extending the draggable, how ''bout simply adding an attribute to the element itself, or using the element''s className? TAG On Jun 14, 2006, at 1:49 AM, Hugo Magalhaes wrote:> Hello all, > I want to extend a draggable object so it has one more attribute (type > attribute, so I can distinguish different draggable types). > Can anyone tell me how to do it? > I''ve search throught the examples (like > http://wiki.script.aculo.us/scriptaculous/show/ExtendClass) but I > can''t seem to understand what I should do. > > Thanks for you help, > H > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Hello Tom, thanks for your help. I''ve added the attribute to the element itself. But now I have another problem: I want to drag some div elements to a droppable (another div), but the place I want to place the draggable depends on where the mouse is. If the mouse is between two div elements inside the droppable, the draggable should be placed between the two divs. How can I do this? Thanks for you help, H On 14/06/06, Tom Gregory <tomg-PGZyUNKar/Q@public.gmane.org> wrote:> Instead of extending the draggable, how ''bout simply adding an > attribute to the element itself, or using the element''s className? > > > TAG > > On Jun 14, 2006, at 1:49 AM, Hugo Magalhaes wrote: > > > Hello all, > > I want to extend a draggable object so it has one more attribute (type > > attribute, so I can distinguish different draggable types). > > Can anyone tell me how to do it? > > I''ve search throught the examples (like > > http://wiki.script.aculo.us/scriptaculous/show/ExtendClass) but I > > can''t seem to understand what I should do. > > > > Thanks for you help, > > H > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
In your Droppable.add, attach an onDrop callback See http://wiki.script.aculo.us/scriptaculous/show/Droppables.add After a quick check of drogdrop.js, it appears the callback has the form: myCallback( draggableElement, droppableElement, event) From there, you''ll likely need to use Event.pointerX(event) and Event.pointerY(event), along with Position.within() for each div in your droppable. (all in the Prototype library) Cheers, TAG On Jun 14, 2006, at 10:09 AM, Hugo Magalhaes wrote:> Hello Tom, > thanks for your help. I''ve added the attribute to the element itself. > But now I have another problem: > > I want to drag some div elements to a droppable (another div), but the > place I want to place the draggable depends on where the mouse is. If > the mouse is between two div elements inside the droppable, the > draggable should be placed between the two divs. How can I do this? > > Thanks for you help, > H > > On 14/06/06, Tom Gregory <tomg-PGZyUNKar/Q@public.gmane.org> wrote: >> Instead of extending the draggable, how ''bout simply adding an >> attribute to the element itself, or using the element''s className? >> >> >> TAG >> >> On Jun 14, 2006, at 1:49 AM, Hugo Magalhaes wrote: >> >> > Hello all, >> > I want to extend a draggable object so it has one more attribute >> (type >> > attribute, so I can distinguish different draggable types). >> > Can anyone tell me how to do it? >> > I''ve search throught the examples (like >> > http://wiki.script.aculo.us/scriptaculous/show/ExtendClass) but I >> > can''t seem to understand what I should do. >> > >> > Thanks for you help, >> > H >> > _______________________________________________ >> > Rails-spinoffs mailing list >> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On further reflection, Sortables has this behavior built in, as is demonstrated in several of the demos. Either use Sortables, or swipe significant portions of its code. TAG On Jun 14, 2006, at 11:34 AM, Tom Gregory wrote:> In your Droppable.add, attach an onDrop callback > See http://wiki.script.aculo.us/scriptaculous/show/Droppables.add > > After a quick check of drogdrop.js, it appears the callback has the > form: > myCallback( draggableElement, droppableElement, event) > > From there, you''ll likely need to use Event.pointerX(event) and > Event.pointerY(event), along with Position.within() for each div in > your droppable. (all in the Prototype library) > > Cheers, > > > TAG > > On Jun 14, 2006, at 10:09 AM, Hugo Magalhaes wrote: > >> Hello Tom, >> thanks for your help. I''ve added the attribute to the element itself. >> But now I have another problem: >> >> I want to drag some div elements to a droppable (another div), but >> the >> place I want to place the draggable depends on where the mouse is. If >> the mouse is between two div elements inside the droppable, the >> draggable should be placed between the two divs. How can I do this? >> >> Thanks for you help, >> H >> >> On 14/06/06, Tom Gregory <tomg-PGZyUNKar/Q@public.gmane.org> wrote: >>> Instead of extending the draggable, how ''bout simply adding an >>> attribute to the element itself, or using the element''s className? >>> >>> >>> TAG >>> >>> On Jun 14, 2006, at 1:49 AM, Hugo Magalhaes wrote: >>> >>> > Hello all, >>> > I want to extend a draggable object so it has one more >>> attribute (type >>> > attribute, so I can distinguish different draggable types). >>> > Can anyone tell me how to do it? >>> > I''ve search throught the examples (like >>> > http://wiki.script.aculo.us/scriptaculous/show/ExtendClass) but I >>> > can''t seem to understand what I should do. >>> > >>> > Thanks for you help, >>> > H >>> > _______________________________________________ >>> > Rails-spinoffs mailing list >>> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >>> >>> _______________________________________________ >>> Rails-spinoffs mailing list >>> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >>> >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs