I'm working with the sortable of jQuery UI, however, I'm not able to enable / disable drop for every ul
with 4 li
(with 4 disable, with less enable, always enabling move the content from ul
to another).
My sortable js are like this:
function ativaSortable()
{
$('.connected').sortable({
connectWith: '.connected',
update: function(event, ui)
{
var nivel = ui.item.parent().parent().attr('id');
atualizaDados(ui.item.index(), nivel, this.id, $(ui.item).attr("id"));
}
});
}
In the atualizaDados()
function it checks if you already have the 4 records to know if the positions of the items in the BD can be, but I do not know how to do so that ul
does not accept the drop if you already have all 4 items. This commented the line that should do the most work did not work!
function atualizaDados(posicao, nivel, linha, id)
{
var totalLinha = $("#"+nivel+" #"+linha+" li");
console.log("POSIÇÃO ["+posicao+ "] NIVEL ["+nivel + "] LINHA [" + linha + "] ID ["+id+"]");
console.log(totalLinha.length);
if(totalLinha.length<=4)
{
// ainda não esta desabilitando quando a linha tem 4 itens.
//$("#"+nivel+">#"+linha).droppable({ disabled: true } );
$.ajax({url:"<?php echo $this->Html->url(array('action'=>'atualizaDadosPosicao')); ?>/"+posicao+"/"+nivel+"/"+linha+"/"+id, async:false}).resposeText;
}
}
How can I resolve this?