Bug Tracker

Modify

Ticket #2704 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

ui.droppable.js and removing droppables

Reported by: colin.johnson Owned by: braeker
Priority: major Milestone: 1.2.4
Component: ui Version: 1.2.3
Keywords: Cc:
Blocking: Blocked by:

Description

I have come across an error when trying to remove a droppable when I have finished with it. I am allowing an <li> element to be dragged onto another <li> element that is a droppable.

If I setup something like this:

$(this).droppable({
	drop: function(ev, ui) {
		// move the dragging element before the droppable
		$(ui.draggable).insertBefore($(this));
		$(REFERENCE_TO_A_DROPPABLE_LI_ELEMENT).remove();
	}
});

I get the following error: this.items has no properties

This is raised on line 236:

if (!this.item.options.disabled && $.ui.intersect(draggable, this, this.item.options.tolerance))

and line 239:

if (!this.item.options.disabled && this.item.options.accept.call(this.item.element,(draggable.currentItem || draggable.element))) {

If I check that this.items exists then the error can be prevented

if (this.item && !this.item.options.disabled && $.ui.intersect(draggable, this, this.item.options.tolerance))

However, I have not got any knowledge of the impact of this change, and tried to actually resolve it without this change with no success. I think some of the issue is around now having a bind on the remove event (line 54) which means the removed elements are correctly taken out of the $.ui.ddmanager.droppables array but perhaps they are still referenced in the array loop starting on line 234?

I have attached an example of the failure, if you try and drag "Node 2" into the very top land area, it will raise the error.

Attachments

ui.droppable.zip Download (41.7 KB) - added by colin.johnson 5 years ago.
Files for reproducing the error

Change History

Changed 5 years ago by colin.johnson

Files for reproducing the error

comment:1 in reply to: ↑ description ; follow-up: ↓ 2 Changed 5 years ago by colin.johnso

Sorry, this should not be listed as a 'Major' priority...can't see how to change that now

comment:2 in reply to: ↑ 1 Changed 5 years ago by colin.johnso

Replying to colin.johnson:

Sorry, this should not be listed as a 'Major' priority...can't see how to change that now

Sorry, accidentally submitted this before changing the component to 'ui' as well.

comment:3 Changed 5 years ago by davidserduke

  • Owner set to paul
  • Component changed from core to ui

comment:4 Changed 5 years ago by paul

  • Owner changed from paul to braeker

comment:5 Changed 5 years ago by paul

  • Status changed from new to closed
  • Resolution set to fixed

I don't know the cause, but I implemented a simple check wether this.options is available in the drop. This should fix it.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.