Opened 5 years ago

Closed 5 years ago

#10328 closed bug (duplicate)

Sortable beforeStop callback plus event.preventDefault() leads to error

Reported by: glennfu Owned by:
Priority: minor Milestone: none
Component: ui.sortable Version: 1.11.0
Keywords: Cc:
Blocked by: Blocking:

Description

I have two lists, one sortable, and one not sortable, but I want to drag from the non-sorting one to the sortable one. In other words, I have a bucket of sortable things, and I have a place from where I can add new items to that list. To achieve this, on the sortbeforestop I call:

var source_table = $(event.target);
var dest_table   = $(ui.item).closest("tbody");
    
if (source_table.is(dest_table) && dest_table.closest("table").is("#my-non-sortable-table")) {
    event.preventDefault();
}

This works perfectly, except afterwards I see there is an error in the console on sortable.js line 1275:

TypeError: this.placeholder[0].parentNode is null
this.placeholder[0].parentNode.removeChild(this.placeholder[0]);

The fix, I'm guessing, would be:

if (this.placeholder[0]) this.placeholder[0].parentNode.removeChild(this.placeholder[0]);

Hope that helps!

Change History (1)

comment:1 Changed 5 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #6054.

Note: See TracTickets for help on using tickets.