Skip to content

Commit 2f630b3

Browse files
committed
changed the revert option name and added -revert- event on revertOnError
1 parent 08e5f78 commit 2f630b3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

jquery.ui.nestedSortable.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
errorClass: 'ui-nestedSortable-error',
2121
listType: 'ol',
2222
maxLevels: 0,
23-
nearestAllowed: 0,
24-
noJumpFix: 0
23+
noJumpFix: 0,
24+
revertOnError: 1
2525
},
2626

2727
_create: function(){
@@ -174,9 +174,17 @@
174174

175175
// If the item is in a position not allowed, send it back
176176
if (this.beyondMaxLevels) {
177+
177178
this.placeholder.removeClass(this.options.errorClass);
178179

179-
if (this.options.nearestAllowed) {
180+
if (this.options.revertOnError) {
181+
if (this.domPosition.prev) {
182+
$(this.domPosition.prev).after(this.placeholder);
183+
} else {
184+
$(this.domPosition.parent).prepend(this.placeholder);
185+
}
186+
this._trigger("revert", event, this._uiHash());
187+
} else {
180188
var parent = this.placeholder.parent().closest(this.options.items);
181189

182190
for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
@@ -185,14 +193,8 @@
185193

186194
parent.after(this.placeholder);
187195
this._trigger("change", event, this._uiHash());
188-
189-
} else {
190-
if (this.domPosition.prev) {
191-
$(this.domPosition.prev).after(this.placeholder);
192-
} else {
193-
$(this.domPosition.parent).prepend(this.placeholder);
194-
}
195196
}
197+
196198
}
197199

198200
$.ui.sortable.prototype._mouseStop.apply(this, arguments);

0 commit comments

Comments
 (0)