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
// Called by any change to the list (add / update / remove)
67
+
onSort:function (/**Event*/evt){
68
+
var itemEl =evt.item; // dragged HTMLElement
69
+
},
70
+
71
+
// The element is removed from the list
56
72
onRemove:function (/**Event*/evt){
57
73
var itemEl =evt.item; // dragged HTMLElement
58
74
},
@@ -63,20 +79,24 @@ new Sortable(el, {
63
79
});
64
80
```
65
81
66
-
#### handle
82
+
83
+
---
84
+
85
+
86
+
#### `handle` option
67
87
68
88
To make list items draggable, Sortable disables text selection by the user. That's not always desirable. To allow text selection, define a drag handler, which is an area of every list element that allows it to be dragged around.
69
89
70
90
```js
71
-
newSortable(el, {
91
+
var sortable =newSortable(el, {
72
92
handle:".my-handle",
73
93
});
74
94
```
75
95
76
96
```html
77
97
<ul>
78
-
<li><spanclass="my-handle">::</span> list item text one
79
-
<li><spanclass="my-handle">::</span> list item text two
98
+
<li><spanclass="my-handle">::</span> list item text one
99
+
<li><spanclass="my-handle">::</span> list item text two
80
100
</ul>
81
101
```
82
102
@@ -86,10 +106,61 @@ new Sortable(el, {
86
106
}
87
107
```
88
108
109
+
110
+
---
111
+
112
+
113
+
### `group` option
114
+
115
+
* name:`string` — group name
116
+
* pull:`true|false|'clone'` — ability to move from the list. `clone` — cloning drag item when moving from the list.
117
+
* put:`true|false|["foo", "bar"]` — the possibility of adding an element from the other list, or an array of names groups, which can be taken.
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
@@ -117,13 +188,15 @@ Serializes the sortable's item `data-id`'s into an array of string.
117
188
118
189
##### sort(order:`String[]`)
119
190
Sorts the elements according to the array.
191
+
120
192
```js
121
193
var order =sortable.toArray();
122
194
sortable.sort(order.reverse()); // apply
123
195
```
124
196
125
197
126
198
##### destroy()
199
+
Removes the sortable functionality completely.
127
200
128
201
129
202
---
@@ -141,7 +214,7 @@ Saving and restoring of the sort.
141
214
```
142
215
143
216
```js
144
-
newSortable(el, {
217
+
Sortable.create(el, {
145
218
group:"localStorage-example",
146
219
store: {
147
220
/**
@@ -185,6 +258,7 @@ new Sortable(el, {
185
258
* toggleClass(el`:HTMLElement`, name`:String`, state`:Boolean`) — add or remove one classes from each element
0 commit comments