Skip to main content

Search and Top Navigation

#2637 closed bug (fixed)

Opened April 02, 2008 02:46PM UTC

Closed May 03, 2008 07:15AM UTC

Last modified February 26, 2009 12:04PM UTC

[BUG+PATCH] ui.droppables: calc position creates undroppables on elements not yet added to DOM

Reported by: spurkis Owned by: eduardo
Priority: major Milestone: 1.5
Component: ui.core Version: 1.2.3
Keywords: ui droppables proportions Cc:
Blocked by: Blocking:

(also posted to jQuery UI Google Group)

Hi there,

I've been trying to create DOM elements, make them droppable, and add

them in one fell swoop... pretty much ala:

var $li1 = $('<li class="one">foo</li>');

$li1.draggable({opacity: 0.5, helper: 'clone'});

var $li2 = $('<li>bar</li>');


accept: '.one',

tolerance: 'pointer',

activeClass: 'droppable-active',

hoverClass: 'droppable-hover',

refreshPositions: true,

drop: function(ev, ui) {

alert('dropped '+ui.draggable+' onto '+this+'!');



I couldn't figure out why the droppables I was creating were getting

'droppable-active' set but never 'droppable-hover'. And it worked for

other droppables I had on the page.

When I looked through ui.droppable.js, I found out that

'refreshPositions' doesn't quite do what it says on the tin - it

refreshes the offsets, but not the proportions.

I've uploaded a patch that does just that (though I can't figure out

how to link to it from here? it's called ui.droppable.js-recalc-

position.patch). Note that I opted to do a recalcProportions() on

droppable.activate() instead of in the drag() method like

prepareOffsets() because I wanted to reduce the time spent

calculating... others may have different opinions. I also made the

mouse pointer calcs a bit less repetitive (and prolly 1x10e-100 s

faster ;-)

Hope this helps,


Attachments (0)
Change History (8)

Changed April 02, 2008 04:07PM UTC by paul comment:1

owner: paulbraeker

Changed April 02, 2008 05:12PM UTC by scottgonzalez comment:2

I haven't tested this at all, but try just changing line 226 of ui.droppable.js from

m[i].item.proportions = ...


m[i].proportions = ...

Changed April 02, 2008 05:26PM UTC by scottgonzalez comment:3

Disregard my previous comment, that line was correct. Paul's going to fix those inconsistencies (#2638).

Changed May 01, 2008 07:14AM UTC by spurkis comment:4

Thanks Scott & Paul!

Changed May 01, 2008 03:24PM UTC by scottgonzalez comment:5

Eduardo, can you verify whether or not this problem still exists? Paul and I both feel that the patch is unnecessary (it's doing redundant work). If the problem still exists, there is a bug or typo somewhere.

Changed May 03, 2008 07:15AM UTC by paul comment:6

resolution: → fixed
status: newclosed

I rechecked, this should be fixed!

Changed May 24, 2008 03:39AM UTC by comment:7

milestone: 1.2.4

Milestone 1.2.4 deleted

Changed February 26, 2009 12:04PM UTC by paul comment:8

milestone: → 1.5