Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

'items' doesn't work on deep descendants #398

Open
i10111pn opened this issue Nov 2, 2015 · 8 comments
Open

'items' doesn't work on deep descendants #398

i10111pn opened this issue Nov 2, 2015 · 8 comments

Comments

@i10111pn
Copy link

i10111pn commented Nov 2, 2015

Hi,

could you please check if it a bug: http://codepen.io/anon/pen/yYjjXm

I have two lists:
red - can be moved
white - can't be moved

So, white list is not gradable before first drag&drop.
But after first drag&drop white list is becoming gradable.

Also we don't have this issue here: http://codepen.io/anon/pen/bVjeBe
It different only by model.

Thanks.

@thgreasi
Copy link
Contributor

thgreasi commented Nov 2, 2015

The items option works as expected but you should only target direct descendants of the sortable directive. Otherwise you will not have an 1to1 match between the ng- model and the DOM elements that are generated by the single child ng-repeat.

@thgreasi
Copy link
Contributor

thgreasi commented Nov 2, 2015

Related to #248

@i10111pn
Copy link
Author

i10111pn commented Nov 2, 2015

What do you mean by "descendants of the sortable directive"?

@thgreasi
Copy link
Contributor

thgreasi commented Nov 2, 2015

The items option should target direct child elements of the ui-sortable directive. The default value is '> *'. Likewise you should use a css selector that starts with '>', otherwise there will be no index matching between the DOM elements and the ng-model array.

@thgreasi thgreasi changed the title 'items' doesn't work as expected 'items' doesn't work on deep descendants Nov 2, 2015
@i10111pn
Copy link
Author

i10111pn commented Nov 3, 2015

It stop working if I'm adding ">" to css selector:
items: "categories > div.category:not(.not-sortable)"

http://codepen.io/anon/pen/yYjjXm

@thgreasi
Copy link
Contributor

thgreasi commented Nov 3, 2015

Likewise you should use a css selector that starts with '>'

I was meaning something like this:
items: "> .category:not(.not-sortable)"

@i10111pn
Copy link
Author

i10111pn commented Nov 4, 2015

It can be solved by handle property.
http://codepen.io/anon/pen/ZbMzgL

Thanks for answers.

@thgreasi
Copy link
Contributor

thgreasi commented Nov 4, 2015

Didn't realized that this was enough for your use case.
I'm glad you found a solution!

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

No branches or pull requests

2 participants