You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+65-5Lines changed: 65 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -71,23 +71,72 @@ When the order is updated, you will receive the following array structure in you
71
71
72
72
### Multiple groups with draggable items
73
73
74
-
When you have multiple lists, each with items that can be moved between those different lists (e.g. Trello), you have to add the following attributes to your html:
75
-
-`wire:sortable-group="methodName"`: This attribute should be added to the html element that encapsulates all lists with. The value of this attribute is the Livewire method that will be executed when an item has been dragged.
74
+
When you have multiple lists, each with items that can be moved between those different lists, you have to add the following attributes to your html:
75
+
-`wire:sortable-group="methodName"`: This attribute should be added to the html element that encapsulates all lists. The value of this attribute is the Livewire method that will be executed when an item has been dragged.
76
76
-`wire:sortable-group.item-group="groupIdentifier"`: This atttribute should be added to the root element of a list with draggable items. The value of this attribute will be used to inform you about the updated order.
77
77
-`wire:sortable-group.item="itemIdentifier"`: This atttribute should be added to each individual draggable item in each list. The value of this attribute will be used to inform you about the updated order.
78
-
-`wire:sortable.handle`: This is an optional attribute. If you provide this attribute, then you will only be able to drag an item by dragging this html element. If you do not provide it, then the complete item will draggable.
78
+
-`wire:sortable-group.handle`: This is an optional attribute. If you provide this attribute, then you will only be able to drag an item by dragging this html element. If you do not provide it, then the complete item will draggable.
When an item is dragged, you will receive the following array structure in the Livewire method you provided to the `wire:sortable-group` directive (in this example, the `updateTaskOrder` method):
100
+
101
+
```php
102
+
[
103
+
[
104
+
'order' => 1, // order of group (starts at 1, not 0)
105
+
'value' => 20, // group id
106
+
'items' => [
107
+
[
108
+
'order' => 1, // order of item within group (starts at 1, not 0)
109
+
'value' => 50, // item id
110
+
]
111
+
]
112
+
]
113
+
]
114
+
```
115
+
116
+
### Multiple draggable groups with draggable items
117
+
118
+
When you have multiple lists, each with items that can be moved between those different lists and the lists themselves also need to be draggable, you have to add the following attributes to your html:
119
+
-`wire:sortable="methodName"`: This attribute should be added to the html element that encapsulates all draggable groups. The value of this attribute is the Livewire method that will be executed when a group has been dragged.
120
+
-`wire:sortable.item="groupIdentifier"`: This atttribute should be added to each individual draggable group. The value of this attribute will be used to inform you about the updated group order.
121
+
-`wire:sortable.handle`: This is an optional attribute. If you provide this attribute, then you will only be able to drag a group by dragging this html element. If you do not provide it, then the complete group will draggable.
122
+
123
+
-`wire:sortable-group="methodName"`: This attribute should be added to the html element that encapsulates all lists. The value of this attribute is the Livewire method that will be executed when an item has been dragged.
124
+
-`wire:sortable-group.item-group="groupIdentifier"`: This atttribute should be added to the root element of a list with draggable items. The value of this attribute will be used to inform you about the updated order.
125
+
-`wire:sortable-group.item="itemIdentifier"`: This atttribute should be added to each individual draggable item in each list. The value of this attribute will be used to inform you about the updated order.
126
+
-`wire:sortable-group.handle`: This is an optional attribute. If you provide this attribute, then you will only be able to drag an item by dragging this html element. If you do not provide it, then the complete item will draggable.
@@ -96,7 +145,7 @@ When you have multiple lists, each with items that can be moved between those di
96
145
</div>
97
146
```
98
147
99
-
When the order is updated, you will receive the following array structure in your Livewire method:
148
+
When an item is dragged, you will receive the following array structure in the Livewire method you provided to the `wire:sortable-group` directive (in this example, the `updateTaskOrder` method):
100
149
101
150
```php
102
151
[
@@ -113,6 +162,17 @@ When the order is updated, you will receive the following array structure in you
113
162
]
114
163
```
115
164
165
+
When a group is dragged, you will receive the following array structure in the Livewire method you provided to the `wire:sortable` directive (in this example, the `updateGroupOrder` method):
166
+
167
+
```php
168
+
[
169
+
[
170
+
'order' => 1, // order of group (starts at 1, not 0)
0 commit comments