I have a page that I have been tasked with adding sortable support to, and the div elements that are being dragged have a <a href> in them with an onClick handler that opens a new window with a preview. Is there a way to keep that onCLick from firing when a sortable is dropped? Sam D _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On Wednesday 14 June 2006 13:34, Samuel DeVore wrote:> I have a page that I have been tasked with adding sortable support to, and > the div elements that are being dragged have a <a href> in them with an > onClick handler that opens a new window with a preview. Is there a way to > keep that onCLick from firing when a sortable is dropped?not easily. you''d have to make your onclick events aware of the fact that there''s a draggable underneath them, and you''d also probably want to make all of the links inside the draggable aware of the draggable as well. My advice on this would be to use the handle: option and specify a part of your div as a handle for the user to grab and drag around with. -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://www.pirate-party.us/ -- defend your rights _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Actually in this case it seems that it was as simple as setting the handle to the surrounding div. Sam D ps. I was heading down the road you suggested when someone suggested trying the handle On 6/15/06, David Rusenko <david-H2teR68TJaDQT0dZR+AlfA@public.gmane.org> wrote:> > Sam, > > Actually, you could create an onChange handler for the sortable which > sets a global variable hasBeenDragged = 1. In your onClick, check if > hasBeenDragged = 1 --> if so, set to 0 and don''t proceed; if not, > continue. > > The problem here is that onChange is only called when the sort order > changes. You could argue that if the sort order doesn''t change in a > sortable, then the user has essentially meant to click on it. Or, if you > didn''t want to argue that, you would most likely have to dig a bit into > the Sortable code and find the location of the drag function, and hack > in the hasBeenDragged variable there. > > Unless I''m missing something, this seems like it should work... > > David Rusenko > _______________________________________________ > 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
Sam, Actually, you could create an onChange handler for the sortable which sets a global variable hasBeenDragged = 1. In your onClick, check if hasBeenDragged = 1 --> if so, set to 0 and don''t proceed; if not, continue. The problem here is that onChange is only called when the sort order changes. You could argue that if the sort order doesn''t change in a sortable, then the user has essentially meant to click on it. Or, if you didn''t want to argue that, you would most likely have to dig a bit into the Sortable code and find the location of the drag function, and hack in the hasBeenDragged variable there. Unless I''m missing something, this seems like it should work... David Rusenko