Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drag-Drop elements between parent frame and child iframe

I am trying to drag-drop elements between parent frame and iframe using jQuery. I have a panel in parent frame which contains some draggable items which can be dropped on the child frame. I tried to search a lot but couldn't find much...

I tried to work around it by appending the element inside the child frame and then trying to trigger draggable on the newly inserted element programmatically, but I got stuck there as well. Couldn't find the proper way to trigger the drag function. (The draggable element has a helper. When I trigger drag by triggering "mousedown.draggable" the position on the ui-draggable element changes but I cannot see the helper.

Thanks!!

like image 439
Kshitiz Avatar asked Feb 04 '13 17:02

Kshitiz


2 Answers

Using HTML5 Drag and Drop API to create Cross Frame and Cross Browser Implementation. http://blog.stackhive.com/post/137799349684/building-a-seamless-drag-and-drop-interface

EDIT - The previous link wasn't valid (dockPHP got rebranded as StackHive) so have written out a more complete post that can help in creating an epic drag and drop interface.

like image 182
Kshitiz Avatar answered Oct 19 '22 01:10

Kshitiz


AFAIK, if iframes come from different domains, this is not doable in a "common" way (unless you control both iframes), browser security measures prevent it, otherwise you could wrap a banking website and steal passwords, for example, when you log in.

Some info on workarounds: http://softwareas.com/cross-domain-communication-with-iframes

If you control both iframes:

Drag & Drop between iframes by sample: http://www.dhtmlx.com/docs/products/dhtmlxTree/samples/05_drag_n_drop/06_pro_drag_frame.html

Cross Browser HTML5 Drag and Drop: http://www.useragentman.com/blog/2010/01/10/cross-browser-html5-drag-and-drop/

Another sample: http://jqfaq.com/how-to-implement-drag-and-drop-between-iframes/

like image 5
Marcos Besteiro López Avatar answered Oct 19 '22 03:10

Marcos Besteiro López