File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed
Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 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 ( ) {
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 -- ) {
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 ) ;
You can’t perform that action at this time.
0 commit comments