Grzesiek Slusarek
2006-Apr-30 20:19 UTC
Draggable - how start action on start dragging and end action on droppping
Hi all. I have got situation that I made element draggable - and when element is dragged I want to start some action (e.g. shown AJAX indicator, and change one of CSS class in dragging element). What is the best way to achieve this? I search source code of the Draggable and I saw that there is 2 method: Draggable.initDrag and Draggable.endDrag so it looks like in initDrag method i should call my own function which do the fing and in endDrag method I should call my own function which cancel behaviour of preview function. Is it better way to do it? ---------------------------------------------------- Grupa dEUS w ramach dwudniowej muzycznej imprezy Alternation Festival #1. http://klik.wp.pl/?adr=http%3A%2F%2Fadv.reklama.wp.pl%2Fas%2Fdues.html&sid=738
Dirk Eschler
2006-May-01 15:27 UTC
Re: Draggable - how start action on start dragging and end action on droppping
Am Sonntag, 30. April 2006 22:19 schrieb Grzesiek Slusarek:> Hi all. I have got situation that I made element draggable - and > when element is dragged I want to start some action (e.g. shown > AJAX indicator, and change one of CSS class in dragging element). > What is the best way to achieve this? I search source code of the > Draggable and I saw that there is 2 method: Draggable.initDrag > and Draggable.endDrag so it looks like in initDrag method i > should call my own function which do the fing and in endDrag > method I should call my own function which cancel behaviour of > preview function. Is it better way to do it?Hello, for the draggables i use starteffect and endeffect (basically that''s onDragStart and onDragEnd in other frameworks). You can overwrite the methods when you create the object. The Wiki lacks a code example, but it works the same way as in the Droppable example. http://wiki.script.aculo.us/scriptaculous/show/Droppables.add However, as for the AJAX indicator there is a built-in mechnism called Ajax.Responders. It''s some kind of global AJAX activity monitor. Excellent stuff. :) Here''s an example, i''m sure you get the idea: //------------------------------------- Ajax.Responders.register({ onCreate: function() { if(Ajax.activeRequestCount > 0) Element.show(id); }, onComplete: function() { if(Ajax.activeRequestCount == 0) Element.hide(id); } }); //------------------------------------- Best Regards, Dirk Eschler -- Dirk Eschler <mailto:dirk.eschler-hi6Y0CQ0nG0@public.gmane.org> http://www.krusader.org