[jQuery] ui sortable - cancel action if list is too long
I have few lists with ui sortable/droppable and I want to have let say
max 4 elements in one. So:
$("ul[id^='sortable']").sortable({
connectWith: '.user-list',
dropOnEmpty: true
})
$(".accept-drop").droppable({
drop: function(event, ui) {
//some code
if($('#sortable'+new_id+" li").size()>4) {
//DO SOMETHING TO STOP SORTABLE
}
});
What code should be there? I've tried to change class to .disabled but
it blocks moving.
$('#sortable'+new_id).sortable("cancel"); causes error. Script allows
to move single elements and whole lists.
I want to be able move elements from all lists but disable drop if
it's too long.
--
Regards,
Robert