Sure.
What I'm doing is this -- removing them from the parent object in the
order I want them to re-appear, then inserting them in that order at
the bottom of the parent object. So if you start out like this:
div#foo
div#bar1
div#bar2
div#bar3
div#bar4
Then we iterate over an array of those IDs that is set in the desired
order:
['bar4','bar1','bar2','bar3']
To iterate over this array, I am using the each() method of
Enumerable. At each step of the array, I am removing the element that
has the same ID as that index of the array. While it is removed from
the DOM with remove(), it's sitting in a variable (implied in my code,
but there in the "chained" methods. To write this more explicitly, I
could say:
var foo = $('foo'); //the parent element
['bar4','bar1','bar2','bar3'].each(function(id){
var elm = $(id);
var bar = elm.remove();
//at this point, foo is missing elm
foo.insert(bar); //default insertion is bottom
});
At each turn of the each() loop, one element would be removed from the
parent by name (so regardless of where in the order of those elements
it exists) and added back to the bottom of the same parent. In this
manner the order of the elements would become the same as the order of
the array.
Walter
On Jun 5, 2009, at 7:18 AM, Daryl wrote:
>
> Sorry I'm not sure how that works, can you please explain a bit more.
>
> Basically I have 4 divs in a row ordered 1,2,3,4
>
> When I press a button I want them to re order themselves 4,1,2,3
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---