If you want the whole list draggable as one entity, you make one draggable. If you want each item draggable on their own, you need to make each one a new draggable. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of dev-bTJQVtzvk6sqDJ6do+/SaQ@public.gmane.org Sent: Wednesday, January 25, 2006 1:07 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails-spinoffs] Make all LI items draggable I have a list and want to make each LI item dragable, do i have to make a "new Draggable" for every one of them, or can i just say make it all draggable. Thanks _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
ok thats what i was worried about... just seems like alot of code... new Draggable(''foo/one'',{revert:true}); new Draggable(''foo/two'',{revert:true}); new Draggable(''foo/three'',{revert:true}); new Draggable(''foo/one/a'',{revert:true}); new Draggable(''foo/one/b'',{revert:true}); my list has over a hundred items.... also, can i call a seperate function on the onDrop? e.g change onDrop:function(){alert(''drop!'')} to onDrop:doTheThing() i tried and it calls the function doTheThing onload. trying to get away from having to put the entire function inside the Droppables.add> If you want the whole list draggable as one entity, you make one > draggable. If you want each item draggable on their own, you need to > make each one a new draggable. > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > dev-bTJQVtzvk6sqDJ6do+/SaQ@public.gmane.org > Sent: Wednesday, January 25, 2006 1:07 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] Make all LI items draggable > > I have a list and want to make each LI item dragable, do i have to make > a > "new Draggable" for every one of them, or can i just say make it all > draggable. > > Thanks > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > The information transmitted in this electronic mail is intended only for > the > person or entity to which it is addressed and may contain confidential, > proprietary, and/or privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance upon, > this information by persons or entities other than the intended recipient > is prohibited. If you received this in error, please contact the sender > and > delete the material from all computers. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Louis, You can do it that way, but you need to drop the brackets. So, your code becomes: onDrop:doTheThing This also means you can't pass anything into the function. Regards, Cam On 1/25/06, Louis Walch <dev@louiswalch.com> wrote:> > also, can i call a seperate function on the onDrop? > > e.g change > onDrop:function(){alert('drop!')} > to > onDrop:doTheThing() > > i tried and it calls the function doTheThing onload. > trying to get away from having to put the entire function inside the > Droppables.add > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
For the draggable creation, use a loop: var liElements = $(mylistID).getElementsByTagName("li"); for (var i = 0; i < liElements.length; i++) { new Draggable($(liElements[i]), {revert:true}); } For the onDrop question, try removing the parens "()" from doTheThing so it''s: onDrop: doTheThing -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Louis Walch Sent: Wednesday, January 25, 2006 1:28 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] Make all LI items draggable ok thats what i was worried about... just seems like alot of code... new Draggable(''foo/one'',{revert:true}); new Draggable(''foo/two'',{revert:true}); new Draggable(''foo/three'',{revert:true}); new Draggable(''foo/one/a'',{revert:true}); new Draggable(''foo/one/b'',{revert:true}); my list has over a hundred items.... also, can i call a seperate function on the onDrop? e.g change onDrop:function(){alert(''drop!'')} to onDrop:doTheThing() i tried and it calls the function doTheThing onload. trying to get away from having to put the entire function inside the Droppables.add> If you want the whole list draggable as one entity, you make one > draggable. If you want each item draggable on their own, you need to > make each one a new draggable. > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of > dev-bTJQVtzvk6sqDJ6do+/SaQ@public.gmane.org > Sent: Wednesday, January 25, 2006 1:07 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: [Rails-spinoffs] Make all LI items draggable > > I have a list and want to make each LI item dragable, do i have tomake> a > "new Draggable" for every one of them, or can i just say make it all > draggable. > > Thanks > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > The information transmitted in this electronic mail is intended onlyfor> the > person or entity to which it is addressed and may containconfidential,> proprietary, and/or privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in relianceupon,> this information by persons or entities other than the intendedrecipient> is prohibited. If you received this in error, please contact thesender> and > delete the material from all computers. > > _______________________________________________ > 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
thanks for the help, but i need to be able to pass in the id.... so i guess i will have to put the whole funciton inside the Droppables.add. however its not letting me... Droppables.add(''droptarget1'',{hoverclass:''dropTargetHover'', accept:[''draggable''], onDrop:function(element){ if (confirm("Are you sure you want to delete this?")) { alert(''DELETE ''+element.id); } });
The onDrop method gets passed 2 arguments, the draggable and the droppaple. So you can do the following... (And yes, you can still pass arguments to functions defined this way, the other guy was wrong (sorry other guy but you were)). doTheThing: function(draggable, droppable) { if (confirm("Are you sure you want to delete this?")) alert("DELETE" + draggable.id); } ... Droppables.add("droptarget1", {... onDrop: doTheThing } If all this is contained in a single class definition, you might get better results using: onDrop: this.doTheThing.bind(this) in the above code. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Louis Walch Sent: Wednesday, January 25, 2006 1:41 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: RE: [Rails-spinoffs] Make all LI items draggable thanks for the help, but i need to be able to pass in the id.... so i guess i will have to put the whole funciton inside the Droppables.add. however its not letting me... Droppables.add(''droptarget1'',{hoverclass:''dropTargetHover'', accept:[''draggable''], onDrop:function(element){ if (confirm("Are you sure you want to delete this?")) { alert(''DELETE ''+element.id); } }); _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.
brilliant, that worked. thanks.> The onDrop method gets passed 2 arguments, the draggable and the > droppaple. So you can do the following... (And yes, you can still pass > arguments to functions defined this way, the other guy was wrong (sorry > other guy but you were)). > > doTheThing: function(draggable, droppable) > { > if (confirm("Are you sure you want to delete this?")) > alert("DELETE" + draggable.id); > } > > ... > Droppables.add("droptarget1", {... > onDrop: doTheThing > } > > > If all this is contained in a single class definition, you might get > better results using: > > onDrop: this.doTheThing.bind(this) > > in the above code. > > > > -----Original Message----- > From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Louis > Walch > Sent: Wednesday, January 25, 2006 1:41 PM > To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > Subject: RE: [Rails-spinoffs] Make all LI items draggable > > thanks for the help, but i need to be able to pass in the id.... so i > guess i will have to put the whole funciton inside the Droppables.add. > > however its not letting me... > > Droppables.add(''droptarget1'',{hoverclass:''dropTargetHover'', > > accept:[''draggable''], > > onDrop:function(element){ > > if (confirm("Are you sure you want to delete this?")) { > > alert(''DELETE ''+element.id); > > } > }); > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > The information transmitted in this electronic mail is intended only for > the > person or entity to which it is addressed and may contain confidential, > proprietary, and/or privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance upon, > this information by persons or entities other than the intended recipient > is prohibited. If you received this in error, please contact the sender > and > delete the material from all computers. > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
On Wednesday 25 January 2006 11:34, Cam McVey wrote:> Louis, > > You can do it that way, but you need to drop the brackets. So, your code > becomes: > > onDrop:doTheThing > > This also means you can''t pass anything into the function.but you can also do: onDrop: function() { doTheThing(args); } if you want to pass arguments -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
You can pass arguments with onDrop: doTheThing if doTheThing is defined as doTheThing: function(draggable, droppable) { ... } Then when onDrop(arg1, arg2) gets called, it will work just fine. When you assign a function to a variable, you get the function, which includes it''s entire signature. In fact, you can pass argument no matter what. If you feel like pass an argument for every letter of the alphabet to ANY function you can... of course the function may or may not have code to handle them, but you can still pass as many as you like in javascript. -----Original Message----- From: rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org [mailto:rails-spinoffs-bounces-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org] On Behalf Of Jeremy Kitchen Sent: Thursday, January 26, 2006 5:00 PM To: rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: Re: [Rails-spinoffs] Make all LI items draggable On Wednesday 25 January 2006 11:34, Cam McVey wrote:> Louis, > > You can do it that way, but you need to drop the brackets. So, yourcode> becomes: > > onDrop:doTheThing > > This also means you can''t pass anything into the function.but you can also do: onDrop: function() { doTheThing(args); } if you want to pass arguments -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org In the beginning was The Word and The Word was Content-type: text/plain -- The Word of Bob. The information transmitted in this electronic mail is intended only for the person or entity to which it is addressed and may contain confidential, proprietary, and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers.