Hi, The only thing I can think of is: Are you absolutely certain that each of those elements actually _has_ an ID? And that there are no duplicate IDs (as, of course, there shouldn't be)?
If they don't all have IDs, just change your loop to: for (var i = 0; i < els.length; i++) { new Draggable(els[i].identify()); } The Prototype `Element#identify` function will auto-assign a unique ID if the element doesn't already have one (it will return the element's existing ID if it does). FWIW, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com On Apr 17, 12:16 pm, Paul <paulgr...@gmail.com> wrote: > Hi all, I was wondering if anyone could help with an issue I'm seeing > when trying to use Draggables with scriptaculous 1.8.1. > > My code is of the following form, where I loop through an array of DOM > elements and create a Draggable providing the element's id: > > for (var i = 0; i < els.length; i++) { > new Draggable(els[i].id); > > } > > But when I drag els[0], els[els.length-1] moves instead! > > Now the Draggable code I'm using contains the following lines from the > Draggable initialisation: > > this.element = $(element); > > if(options.handle && Object.isString(options.handle)) > this.handle = this.element.down('.'+options.handle, 0); > > if(!this.handle) this.handle = $(options.handle); > if(!this.handle) this.handle = this.element; > > When this code is executed the first time, "this.element" is undefined > and "this.handle" is undefined, which I would expect. The > initialisation completes with "this.element" set to the DOM element > matching els[0].id, and "this.handle" also set to this DOM element (as > I don't provide an explicit handle CSS class). > > But the 2nd time this is executed, "this.element" and "this.value" > have the values from the previous execution! > > Now this isn't a problem for "this.element", as this value is always > overwritten. "this.handle" is NOT always overriden though. Again, I > don't provide a handle CSS class, so the first IF is not successful. > Nor are the 2nd and 3rd IFs, because "this.handle" is already set! > (incorrectly in my opinion). > > Has anyone seen this before, or could point out any glaring errors I > have made? > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To post to this group, send email to prototype-scriptacul...@googlegroups.com. > To unsubscribe from this group, send email to > prototype-scriptaculous+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/prototype-scriptaculous?hl=en. -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.