Skip to main content

Search and Top Navigation

#5727 closed bug (fixed)

Opened June 14, 2010 03:16PM UTC

Closed May 21, 2013 02:12AM UTC

Last modified April 24, 2014 12:02PM UTC

Draggable: cannot drag element inside iframe

Reported by: bgrins Owned by:
Priority: minor Milestone: 1.11.0
Component: ui.draggable Version: 1.8.2
Keywords: iframe, draggable, mouse Cc:
Blocked by: Blocking:
Description

I wanted to drag an element inside iframe, but be able to instantiate that from the parent document. Something like: $("iframe#test").contents().find("#draggable").draggable();

This used to throw errors and not work, but I was able to fix it pretty easily by updating calls from "document" to "ownerDocument" inside mouse.js, core.js, and draggable.js.

This change should not break existing code, since the ownerDocument of the element will just be "document" in a traditional situation (as far as I know).

Please see the test case, which was taken out of the development bundle /demos/ folder (copy the two html files into the folder and run it to see the problem).

If you do not feel this minor fix is necessary, that is fine - but it would make my ability to upgrade UI versions much easier (not having to manually patch the files every time), and may help someone else who is having this problem.

Attachments (2)
  • defaultIframe.html (0.9 KB) - added by bgrins June 14, 2010 03:17PM UTC.

    Test case: put into /demos/draggable to run

  • iframe.html (0.2 KB) - added by bgrins June 14, 2010 03:17PM UTC.

    Test case: put into /demos/draggable to run

Change History (20)

Changed June 14, 2010 03:29PM UTC by bgrins comment:1

I have the code to fix this issue, but since it is multiple files, it seems I cannot upload it over the github web interface, so I will need to download and learn how to use git before I can author the fix.

Changed June 14, 2010 04:20PM UTC by bgrins comment:2

Committed to github: http://github.com/bgrins/jquery-ui/commit/c11cad4f538ba521a725174e12f5bf13c5fda7e9

Let me know if I need to do something more for this.

Changed August 16, 2010 08:01PM UTC by bgrins comment:3

Are there any updates on this item? I see that it is still a problem in the latest 1.9 code base.

Changed October 10, 2010 11:53AM UTC by nbt comment:4

I'd also love to see this fix in the next version. draggable and resizable items do not work inside an iframe when initialized from the parent document, this fix works great.

Changed May 06, 2011 12:13AM UTC by tobio85 comment:5

I'd love to see this bug fixed in the next version also. Any comment guys?

Changed June 17, 2011 03:39PM UTC by ibleistift comment:6

_comment0: This patch should be included in the official build...1308325232435786

This patch should be included in the official build...

bgrins: Did you submit a pull request?

Changed October 11, 2012 09:07PM UTC by scottgonzalez comment:7

milestone: TBD2.0.0

Changed October 11, 2012 09:17PM UTC by bgrins comment:8

scott.gonzalez, if I were to pull down the latest code and submit a pull request with the updated patch from this case would it be accepted?

Changed October 11, 2012 09:23PM UTC by scottgonzalez comment:9

_comment0: It depends on the complexity of the patch, but yes. Not that we now have `this.document` which is a jQuery object pointing to the correct document, so that should be used.1360098124387922

It depends on the complexity of the patch, but yes. Note that we now have this.document which is a jQuery object pointing to the correct document, so that should be used.

Changed October 26, 2012 04:50AM UTC by mikesherov comment:10

status: newopen

Changed February 05, 2013 09:02PM UTC by scottgonzalez comment:11

@bgrins are you still interested in submitting an updated PR for this?

Changed February 05, 2013 09:13PM UTC by bgrins comment:12

Sure, sounds good. I'll send a pull request.

Changed February 06, 2013 03:49PM UTC by bgrins comment:13

@scott.gonzalez I have a preliminary version of this working here: https://github.com/bgrins/jquery-ui/compare/5727. If you pull that branch down you can navigate to /jquery-ui/tests/visual/draggable/draggable_iframe.html to see a little demo page.

I also wanted to get some feedback about something before I commit it: https://gist.github.com/bgrins/4723365#file-ui-iframe-mouseup-js-L6. If you mouseup on the parent document it currently will not cancel it the next time a move fires (similar to the issue with IE on mousing out of the browser window). That extra condition in the gist solves that problem. Does this make sense?

Changed February 06, 2013 10:45PM UTC by scottgonzalez comment:14

Replying to [comment:13 bgrins]:

I also wanted to get some feedback about something before I commit it: https://gist.github.com/bgrins/4723365#file-ui-iframe-mouseup-js-L6. If you mouseup on the parent document it currently will not cancel it the next time a move fires (similar to the issue with IE on mousing out of the browser window). That extra condition in the gist solves that problem. Does this make sense?

Yeah, that makes sense. I'd make the comment more generic, like "Handle when the mouseup occurrs in another frame." This won't actually work properly in Firefox or Opera, which both have event.which set to 1 when during a move with no buttons down, but it's certainly won't make the situation any worse in those browsers.

Changed February 06, 2013 10:46PM UTC by scottgonzalez comment:15

Can you send a pull request so that it's easier to comment on the code? I can't comment on a compare view, I'd need to find the specific commit for the line I want to comment on. Thanks.

Changed May 21, 2013 02:12AM UTC by Brian Grinstead comment:16

resolution: → fixed
status: openclosed

Draggable: enabled draggable from within iframe. Fixed #5727 - draggable: cannot drag element inside iframe

Changeset: 24756a978a977d7abbef5e5bce403837a01d964f

Changed May 21, 2013 02:13AM UTC by mikesherov comment:17

milestone: 2.0.01.11.0

Changed October 11, 2013 01:28PM UTC by tj.vantoll comment:18

#9594 is a duplicate of this ticket.

Changed February 26, 2014 02:50PM UTC by scottgonzalez comment:19

#7039 is a duplicate of this ticket.

Changed April 24, 2014 12:02PM UTC by scottgonzalez comment:20

#9993 is a duplicate of this ticket.