On Nov 7, 12:24 am, "T.J. Crowder" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > Yes I know this possibility. I though about it, but I can not use
> > it... and I don't think the bind problem will be fix in that way ;)
>
> I'm pretty sure it will.  Did you try it?  I did a trivial test, and
> it worked fine.  Here's my version of moveDown, which differs slightly
> from Rob's as it uses Prototype-isms:

It's a little bit different, it expects elm to be the element to be
moved, whereas what I posted expects the event to come from an element
inside the element to be moved, e.g.:

  <div onclick="moveDown(this);">
    <button ...> ... </button>
  </div>
  <div onclick="moveDown(this);">
    <button ...> ... </button>
  </div>


>
> function moveDown(elm)
> {
>     var next;
>
>     elm = $(elm);
>     next = elm.next();
>     if (next)
>     {
>         elm.remove();
>         next.insert({after: elm});


I don't think there's any need to remove then insert, you can just
insert the node in the new location.  Coupled with a bit of standard
DOM, there's no need for the if statement - the entire block can be
replaced with:

  elm.parentNode.insertBefore(elm, next.nextSibling);


and the function becomes:

  function moveDown(el) {
    var next = $(el).next();
    el.parentNode.insertBefore(el, next.nextSibling);
  }

Each to their own.  :-)


--
Rob
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to