angular-ui / ui-sortable

jQuery UI Sortable for AngularJS
http://angular-ui.github.io/ui-sortable/
MIT License
1.26k stars 443 forks source link

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

Open i10111pn opened 8 years ago

i10111pn commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

Related to #248

i10111pn commented 8 years ago

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

thgreasi commented 8 years ago

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.

i10111pn commented 8 years ago

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

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

thgreasi commented 8 years ago

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

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

i10111pn commented 8 years ago

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

Thanks for answers.

thgreasi commented 8 years ago

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