dougal85-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-24 16:50 UTC
Drag and Drop problem
Hi, I have made an object in JavaScript that uses the scriptolicious library to help me with drag and drop and various other things. The class has a method to make itself draggable. I have added this method at the bottom so you can see it, It''s mostly copied from an example I found on the scriptolicious documentation (i think). This works fine, the problem is when I have add a second instance of the same class, in a different variable etc. it stops working on the first one and only works in the last added div. I figure it must be overriding some of the settings somewhere and therefore only using them in the last added element. However, I cant see what would make this happen. Please give me and suggestions that you have or if I am totally off track, please point me in the right direction. I have a fair sum of programming experience but JavaScript confuses me somewhat. Dougal -------------------------------------------- this.makeDraggable = function(){ qb.log.add("Adding Drag"); new Draggable(this.divId,{ 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, 11, parent_dimensions.width - element_dimensions.width + 9), constrain(y, 11, parent_dimensions.height - element_dimensions.height + 9)]; }, scroll:window, handle: "table" + this.id + "hand", zindex:9, revert:false }); } --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---