Sorry guys .. had no time to explain further, since we were close to dead end.
Here's what i'm using:
There are three divs with the '.groupWrapper' class applied to them, #listaUno #listaDos #listaInicial . There are two kinds of div modules, all floated left, with basically different widths, 167x159 and 342x159, and the containers #listaUno has a set width of 346px (can hold two small modules or one big one), while #listaDos has 690px (up to four small modules).
Using Sortables from the jQuery-UI ..
$(document).ready(function(){
//change png to gif for IE as its very jumpy
if ($.browser.msie) {
$("img.iconico").attr("src", function() {
valor = this.src.replace(".png",".gif");
return valor;
});
}
//all three groupWrapper div elements are now draggable
$(".groupWrapper").sortable({
connectWith: '.groupWrapper',
items: 'div',
scroll: true,
opacity: 0.6,
receive: function(event, ui) { hemosCambiado(); }
});
$(".groupWrapper").disableSelection();
});
function init() {
$(".groupWrapper").sortable({
connectWith: '.groupWrapper',
items: 'div',
scroll: true,
opacity: 0.6,
receive: function(event, ui) { hemosCambiado(); }
});
$(".groupWrapper").disableSelection();
};
function hemosCambiado() {
var obj;
elemListaUno = $('#listaUno div').size(); //num elements in listaUno
elemListaDos = $('#listaDos div').size(); //num elements in listaDos
elemListaInicial = $('#listaInicial div').size(); //num elements in listaInicial
anchoLista1 = $('#izquierda').width(); //should be 346px;
anchoLista2 = $('#caja-modulos2').width(); //should be 690px;
//listaUno should have 2 or less elements, less than given width
anchoElems1 = 0;
$('#listaUno div').each( function(i,elem) {
anchoElems1 += $(elem).width();
});
if((elemListaUno>2) || (anchoElems1>anchoLista1)){
//surplus elements are sent back to listaInicial
$('#listaInicial').append($('#listaUno div:last-child'));
}
//listaUno should have 4 or less elements, less than given width
anchoElems2 = 0;
$('#listaDos div').each( function(i,elem) {
anchoElems2 += $(elem).width();
});
if((elemListaDos>4) || (anchoElems2>anchoLista2)){
//surplus elements are sent back to listaInicial
$('#listaInicial').append($('#listaDos div:last-child'));
}
$(".groupWrapper").sortable( 'refresh' );
init(); //for some reason, elements appended aren't included as dragable again in IE versions, so the need to be initialized again.
}
This works pretty well on FireFox, IE7, Safari, etc ... but on IE6, elements which are dragged, do some jumpy stuff under other page elements, or get linked to the mouse but 500px away from it, and different other messy stuff ..