mootools sort of list
Hi I want to sort an list in mootools that look like this
-
some data here
some data here
some data here
some data here
some data here
some data here
IT is using FLOAT:LEFT property of css and fix width so it looks like
__________ ___________ __________ |ITEM 1 | | Item2 |开发者_Python百科 |Item 3 | |________| |__________| |_________| __________ ___________ __________ |ITEM 4 | | Item5 | |Item 6 | |________| |__________| |_________|
If i want to sort like 4th item interchanges with item 1 and item 2 with item 6 and item 3 with item 5 Can you guide me how do i do this? Using Mootools at RUntime! and this change need to come from php array i.e. Need to be dynamic .Please help me to learn this
Hi. Here is an example of what you want:
http://jsfiddle.net/YJugE/2/
The main difference from the mootools demo is using a list to sort, not a set of divs
<div id="container">
<ul>
<li class="red sort">red</li>
<li class="red sort">red</li>
<li class="red sort">red</li>
<li class="red sort">red</li>
<li class="red sort">red</li>
<li class="red sort">red</li>
</ul>
</div>
You could get a set of divs to work the way you want, but you would have to do a lot more css work
As far as I can tell, Mootools does not support a setup like you are trying to do. On the Doc page for Fx.Sort, the only supported styles are Horizontal and Vertical, none of which for for what you are trying to do
I've played with swapping elements before, here's a jsfiddle that may give you ideas:
http://jsfiddle.net/dimitar/ZwMUH/
in a nutshell though - if you disregard the Fx side of things:
get a list of the divs into a html collection (array of sorts) swap each pair or reorder it any way you like. loop through it and inject the elements 1 by 1 into the parent in their new order.
that's about it. prototype to swap 2 array elements:
Array.implement({
swap: function(x, y) {
var t = this[x];
this[x] = this[y];
this[y] = t;
return this;
}
});
the rest is up to you.
精彩评论