@@ -36,4 +36,48 @@ test("#3019: Stop fires too early", function() {
36
36
37
37
} ) ;
38
38
39
+ test ( '#4752: link event firing on sortable with connect list' , function ( ) {
40
+ var fired = { } ,
41
+ hasFired = function ( type ) { return ( type in fired ) && ( true === fired [ type ] ) ; } ;
42
+
43
+ $ ( '#sortable' ) . clone ( ) . attr ( 'id' , 'sortable2' ) . insertAfter ( '#sortable' ) ;
44
+
45
+ $ ( '#main ul' ) . sortable ( {
46
+ connectWith : '#main ul' ,
47
+ change : function ( e , ui ) {
48
+ fired . change = true ;
49
+ } ,
50
+ receive : function ( e , ui ) {
51
+ fired . receive = true ;
52
+ } ,
53
+ remove : function ( e , ui ) {
54
+ fired . remove = true ;
55
+ }
56
+ } ) ;
57
+
58
+ $ ( '#main ul li' ) . live ( 'click.ui-sortable-test' , function ( ) {
59
+ fired . click = true ;
60
+ } ) ;
61
+
62
+ $ ( '#sortable li:eq(0)' ) . simulate ( 'click' ) ;
63
+ ok ( ! hasFired ( 'change' ) , 'Click only, change event should not have fired' ) ;
64
+ ok ( hasFired ( 'click' ) , 'Click event should have fired' ) ;
65
+
66
+ // Drag an item within the first list
67
+ fired = { } ;
68
+ $ ( '#sortable li:eq(0)' ) . simulate ( 'drag' , { dx : 0 , dy : 40 } ) ;
69
+ ok ( hasFired ( 'change' ) , '40px drag, change event should have fired' ) ;
70
+ ok ( ! hasFired ( 'receive' ) , 'Receive event should not have fired' ) ;
71
+ ok ( ! hasFired ( 'remove' ) , 'Remove event should not have fired' ) ;
72
+ ok ( ! hasFired ( 'click' ) , 'Click event should not have fired' ) ;
73
+
74
+ // Drag an item from the first list to the second, connected list
75
+ fired = { } ;
76
+ $ ( '#sortable li:eq(0)' ) . simulate ( 'drag' , { dx : 0 , dy : 150 } ) ;
77
+ ok ( hasFired ( 'change' ) , '150px drag, change event should have fired' ) ;
78
+ ok ( hasFired ( 'receive' ) , 'Receive event should have fired' ) ;
79
+ ok ( hasFired ( 'remove' ) , 'Remove event should have fired' ) ;
80
+ ok ( ! hasFired ( 'click' ) , 'Click event should not have fired' ) ;
81
+ } ) ;
82
+
39
83
} ) ( jQuery ) ;
0 commit comments