Ticket #7925 (closed bug: notabug)
droppable prepareOffsets sets incorrect offset when droppable is in an iframe
| Reported by: | reevesm | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | 1.9.0 |
| Component: | ui.droppable | Version: | 1.8.14 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
version: jquery-ui-1.8.14 browser: chrome os: windows
To reproduce:
- Create a draggable element using jQueryUI draggable API outside of your iframe
- Create droppable elements within an iframe (iframe is in middle of the page) on the same page and alert when element is dragged over the droppable within the iframe.
var body = $('#iframe').contents().find('body'); $(body).droppable({
over:function(event,ui) {
alert('over droppable');
}
});
Result: The alert will not fire when dragging over the iframe but will fire when the element is dragged into a position above the iframe
Expected Result: The alert fires when dragging over the body element in the iframe.
See $.ui.ddmanager.prepareOffsets. It appears that m[i].offset is incorrect.
Change History
comment:1 Changed 17 months ago by scott.gonzalez
- Status changed from new to closed
- Resolution set to invalid
comment:2 Changed 16 months ago by ddphoto
I had implemented a workaround to enable drag&drop with iframe. in $.ui.ddmanager.prepareOffsets I change the offset to handle the iframe scrolling & the iframe position.
juste after m[i].offset = m[i].element.offset();
// handle iframe scrolling
m[i].offset.top -= m[i].element.parents().find("html,body").scrollTop();
m[i].offset.left -= m[i].element.parents().find("html,body").scrollLeft();
// iframe positioning
if( this.current.options.iframeOffset )
{
m[i].offset.top += this.current.options.iframeOffset.top;
m[i].offset.left += this.current.options.iframeOffset.left;
}
where iframe offset come from the draggable option like
$( "div" ).draggable({
iframeFix: true,
appendTo: 'body',
containment: 'window',
helper: "clone",
iframeOffset: $("#frame").offset()
});
Tested on FF 8.0.1 & Chrome 16


We don't support cross-window dragging.