Skip to content

Commit ad13321

Browse files
committed
Sortable: Pass this to _uiHash() when firing 'remove' events
Fixes #9738: Remove event object doesn't contain sender when moving an item between connected sortables.
1 parent 6ec452c commit ad13321

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

tests/unit/sortable/sortable_events.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,36 @@ test("#4752: link event firing on sortable with connect list", function () {
227227
test("receive", function() {
228228
ok(false, "missing test - untested code is broken code.");
229229
});
230+
*/
230231

231232
test("remove", function() {
232-
ok(false, "missing test - untested code is broken code.");
233+
expect( 8 );
234+
235+
var hash,
236+
removeCount = 0,
237+
item = $( "#sortable" ).find( "li:last" );
238+
239+
$( ".connectWith" ).sortable({
240+
connectWith: ".connectWith",
241+
remove: function( e, ui ) {
242+
hash = ui;
243+
removeCount++;
244+
}
245+
});
246+
247+
item.simulate( "drag", {
248+
dy: 40
249+
});
250+
251+
ok( hash, "remove event triggered" );
252+
ok( !hash.helper, "UI should not include: helper" );
253+
ok( hash.placeholder, "UI hash includes: placeholder" );
254+
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
255+
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
256+
equal( hash.item.html(), item.html(), "UI hash includes: item" );
257+
equal( hash.sender.html(), $( "#sortable" ).html(), "UI hash includes: sender" );
258+
equal( removeCount, 1, "remove fires only once" );
233259
});
234-
*/
235260

236261
test( "over", function() {
237262
expect( 8 );

ui/jquery.ui.sortable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ $.widget("ui.sortable", $.ui.mouse, {
11811181
// events.
11821182
if (this !== this.currentContainer) {
11831183
if(!noPropagation) {
1184-
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
1184+
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash(this)); });
11851185
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
11861186
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
11871187
}

0 commit comments

Comments
 (0)