How ember-sortable V2 components work together
masterThe V2 architecture of ember-sortable is built using contextual components that follow a hierarchical structure. This design allows for composability, nesting, and customizability.
There are three primary components:
sortable-group: The top-level container. It manages the main sorting logic and requires amodelGroup(a shallow copy of the models to be sorted). It yieldssortable-itemand other properties.sortable-item: Represents an individual model within the group. It yieldssortable-handleand other properties.sortable-handle: The entry point for sorting. This component connects a custom handle to thesortable-groupmainframe. It is required to initiate drag or keyboard reordering.
This structure supports nested sortable elements, meaning a sortable-group can be rendered inside a sortable-item of another group.
{{#ember-sortable::sortable-group
modelGroup=modelGroup
onSubmit=(action "onSubmit")
onDragStart=(action "onDragStart")
onDragEnd=(action "onDragEnd")
as |group|
}}
{{#each group.modelGroup as |singleModel index|}}
{{#group.item
model=singleModel
index=index
as |item|
}}
{{!-- You can nest another "sortable-group" here --}}
{{!-- Content goes here --}}
{{#item.handle}}
{{!-- Handle goes here --}}
{{/item.handle}}
{{/group.item}}
{{/each}}
{{/ember-sortable::sortable-group}}