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

Setting Minimum List Items with Pull #1054

Closed
deltoss opened this issue Mar 4, 2017 · 1 comment
Closed

Setting Minimum List Items with Pull #1054

deltoss opened this issue Mar 4, 2017 · 1 comment

Comments

@deltoss
Copy link

deltoss commented Mar 4, 2017

I'm trying to create a list with a minimum length of 2 following the official documentations, but it doesn't seem to actually work.

var firstListOptions = {
	group: {
		name: 'myGroup',
		pull: function (to, from) { 
			return from.el.children.length > 2; 
		}
	},
};
Sortable.create(firstList, firstListOptions);

The problem is the children.length is never less then 2. After I move an item, the element I dragged and dropped still exist in the original list, but hidden with 'display:none' style, so children.length isn't really accurate, as it also counts hidden elements.

It seems the behaviour of hiding dragged list items is only when I specify the pull option, otherwise it would remove the item being dragged. This also affects the "toArray()" method where it gets values of sortable lists, including the hidden list items which isn't desired. Is there anyway I can get this to work correctly?

Full Code:
http://jsbin.com/vigejoyena/1/edit?html,js,output

@deltoss deltoss changed the title Using Pull Option Makes List Items Hidden Setting Minimum List Items with Pull Mar 4, 2017
@owen-m1
Copy link
Member

owen-m1 commented Jan 15, 2019

Solved in 1.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants