I am trying to customize a somme drag-and-drop view of a wysiwyg editor using jQuery UI.
I have successfully configured the elements, but they have strange behavior.
It is almost impossible to sort items due to constant flickering.
i configure my draggables as follows:
el.draggable({ containement:'.main-form-container', revert: "invalid", connectToSortable: '.sortable' }).disableSelection();
If I don't set it as draggable, the sortable will place the placeholder on itself! why?
Sometimes, when an element falls into another, it becomes ONE draggable element and seems to be glued together. although this seems to be fixed with an overriding sortable update:
update: function (event, ui) { $(ui.item).css({ position: 'relative', top:0, left:0, width: 'auto' });
and setupDandD method:
setupDandD($('.form-container')); function setupDandD(el) { el.draggable({ containement:'.main-form-container', revert: "invalid", connectToSortable: '.sortable' }).disableSelection(); el.droppable({ accept: '[data-section="toolbox"]', greedy: true, hoverClass: 'droppable-hovered', drop: handleDrop }).disableSelection(); el.filter('.sortable').sortable({ tolerance:'pointer', containement:'.main-form-container', connectWith: ".sortable:not(#" + $(this).id + ")", revert: 'invalid', helper: function () { return $(this); }, update: function (event, ui) { console.log('here'); $(ui.item).css({ position: 'relative', top:0, left:0, width: 'auto' }); setupDandD($(ui.item)); } }).disableSelection(); };
I guess I need to dial some kind of event somewhere on the sortable, but now I'm completely lost ...
javascript jquery jquery-ui drag-and-drop
Jmorvan
source share