Skip to content

Nesting with dynamically inherited class names #1739

Open
@designosis

Description

@designosis

First, SortableJS is working perfectly. This is a request for ideas on how to modify it to behave in a slightly different way.

The following ... https://jsbin.com/zebiqik/edit?html,css,js,output ... is a nested sortable with a twist: When a list item with class nested-1 is dragged into a nested-3 group, it becomes nested-3.

I can think of many reasons why this approach would be useful. In the jsbin above, for example, all handles stay on the far left, and indenting items is managed by class. This could of course be done in the current nested methods with position: absolute, but there are other reasons to want the class to change depending on where you drag it.

As-is, the javascript doesn't recursively increment children items. So you can drag 1 (or any non-parent item) anywhere, and it inherits the class correctly. But dragging a nested group will usually fail.

Does anyone have any jQuery or javascript tips on the most elegant approach to recursively incrementing nested items?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementQuality of life changes to existing featuresquestionquestions from the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions