This repository was archived by the owner on Sep 8, 2020. It is now read-only.
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Model and DOM get sometimes out of sync when using nested connected lists #189
Closed
Description
There is a problem when using sortable with nested connected lists. (Example: http://codepen.io/anon/pen/zLBvq). This seem to happen when a child element in a nested list is dragged outside of the outer container so that there is no placeholder position update. The dragged element is moved to the top of the outer container in the model (and DOM) and the nested list's DOM is restored to the original contents (thus showing the element although it is not in the model).
It seems that in the problem case there is only one one update event and the model and DOM get out of sync. I was able to work around the problem by canceling the sort in the remove callback if the first update is missing.
callbacks.remove = function(e, ui) {
//Workaround for a problem observed in nested connected lists.
//There should be an 'update' event before remove when moving
//elements. If the event did not fire, cancel sorting.
if (angular.isUndefined(ui.item.sortable.dropindex)) {
element.sortable('cancel');
ui.item.sortable.cancel();
}
// --- end of workaround ---
// Remove the item from this list's model and copy data into item,
// so the next list can retrive it
if (!ui.item.sortable.isCanceled()) {
scope.$apply(function() {
ui.item.sortable.moved = ngModel.$modelValue.splice(
ui.item.sortable.index, 1)[0];
});
}
};
Metadata
Metadata
Assignees
Labels
No labels