1
I’m working with the sortable jQuery UI, however, I am unable to enable/disable the drop for each ul
with 4 li
(with 4 disabled, with less enabled, always allowing to move the content of ul
to another ).
My sortable js ta so:
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 function atualizaDados()
he checks if he already has the 4 records to know if he can the positions of the items in the BD, however, I do not know how to do ul
do not accept the drop if you already have all 4 items. This commented the line that should do the job no longer worked!
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 fix this ?