Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue items are always cloned #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion knockout-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
var removeOperation = currentOperation.event.type === 'remove' ? currentOperation : existingOperation,
addOperation = currentOperation.event.type === 'add' ? currentOperation : existingOperation;

addOperation.event.groupOption = parentBindings.sortable.options.group;

moveItem(itemVM, removeOperation.collection, addOperation.collection, addOperation.event.clone, addOperation.event);
}
},
Expand Down Expand Up @@ -151,7 +153,13 @@
fromArray.splice(originalIndex, 1);
// Update the array, this will also remove sortables "unbound" clone
from.valueHasMutated();
if (clone && from !== to) {

var groupOption = e.groupOption;
// See the option at https://github.com/SortableJS/Sortable#options
// group: { name: 'shared', pull: 'clone' }
var cloneable = typeof groupOption === 'object' && groupOption.pull === 'clone';

if (cloneable && clone && from !== to) {
// Read the item
fromArray.splice(originalIndex, 0, itemVM);
// Force knockout to update
Expand Down