@@ -64,6 +64,45 @@ describe('uiSortable', function() {
6464 } ) ;
6565 } ) ;
6666
67+ it ( 'should update model when sorting between sortables of different scopes' , function ( ) {
68+ inject ( function ( $compile , $rootScope ) {
69+ var elementTop , elementBottom ,
70+ wrapperTop , wrapperBottom ,
71+ itemsTop , itemsBottom ;
72+ wrapperTop = $compile ( '<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsTop"><li ng-repeat="item in itemsTop" id="s-top-{{$index}}">{{ item }}</li></ul></div>' ) ( $rootScope ) ;
73+ wrapperBottom = $compile ( '<div ng-controller="dummyController"><ul ui-sortable="opts" class="cross-sortable" ng-model="itemsBottom"><li ng-repeat="item in itemsBottom" id="s-bottom-{{$index}}">{{ item }}</li></ul></div>' ) ( $rootScope ) ;
74+
75+ host . append ( wrapperTop ) . append ( wrapperBottom ) . append ( '<div class="clear"></div>' ) ;
76+ $rootScope . $apply ( function ( ) {
77+ wrapperTop . scope ( ) . itemsTop = itemsTop = [ 'Top One' , 'Top Two' , 'Top Three' ] ;
78+ wrapperBottom . scope ( ) . itemsBottom = itemsBottom = [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ;
79+ $rootScope . opts = { connectWith : '.cross-sortable' } ;
80+ } ) ;
81+
82+ elementTop = wrapperTop . find ( '> [ui-sortable]' ) ;
83+ elementBottom = wrapperBottom . find ( '> [ui-sortable]' ) ;
84+
85+ var li1 = elementTop . find ( ':eq(0)' ) ;
86+ var li2 = elementBottom . find ( ':eq(0)' ) ;
87+ simulateElementDrag ( li1 , li2 , 'below' ) ;
88+ expect ( itemsTop ) . toEqual ( [ 'Top Two' , 'Top Three' ] ) ;
89+ expect ( itemsBottom ) . toEqual ( [ 'Bottom One' , 'Top One' , 'Bottom Two' , 'Bottom Three' ] ) ;
90+ expect ( itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
91+ expect ( itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
92+
93+ li1 = elementBottom . find ( ':eq(1)' ) ;
94+ li2 = elementTop . find ( ':eq(1)' ) ;
95+ simulateElementDrag ( li1 , li2 , { place : 'above' , extradx : - 20 , extrady : - 10 } ) ;
96+ expect ( itemsTop ) . toEqual ( [ 'Top Two' , 'Top One' , 'Top Three' ] ) ;
97+ expect ( itemsBottom ) . toEqual ( [ 'Bottom One' , 'Bottom Two' , 'Bottom Three' ] ) ;
98+ expect ( itemsTop ) . toEqual ( listContent ( elementTop ) ) ;
99+ expect ( itemsBottom ) . toEqual ( listContent ( elementBottom ) ) ;
100+
101+ $ ( elementTop ) . remove ( ) ;
102+ $ ( elementBottom ) . remove ( ) ;
103+ } ) ;
104+ } ) ;
105+
67106 it ( 'should update model when sorting a "falsy" item between sortables' , function ( ) {
68107 inject ( function ( $compile , $rootScope ) {
69108 var elementTop , elementBottom ;
0 commit comments