Sorry guys .. did not have time to explain further, since we were close to a dead end. Here is what I use:
There are three divs with the class '.groupWrapper' applied to them, #listaUno #listaDos #listaInicial. There are two types of div modules: all floating on the left, with different widths of 167x159 and 342x159, and #listaUno containers have a set width of 346px (can contain two small modules or one large), and #listaDos has 690px (up to four small modules).
Using sorters from 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 very well on FireFox, IE7, Safari, etc., but on IE6 elements that are being dragged do some overloaded things under other page elements or are connected to the mouse, but at a distance of 500 pixels from it, other messy things ..
source share