Drag and Drop across Windows

Posted on 2013-02-01
Last Modified: 2013-02-01
I have a page that loads and then that page's JavaScript opens a popup window that will become a gallery. The user will upload images, using JavaScript and PHP that is part of the popup gallery window, and these uploaded  images will be displayed in the gallery window that we popped up

Once several images have been uploaded and displayed in the gallery window I would like to drag and drop them into the primary window. Actually I'd like to leave the image in the gallery and just drag a ghost image across and drop it in the main window, so we end with the image in both windows.

This seems a bit tricky since the main widow and the popup gallery window are different JavaScript execution contexts.  How can I implement a jQuery (or YUI) Drag and Drop that works from the popup window to the main window?

Thanks for any ideas.
Question by:steva
LVL 11

Accepted Solution

mcnute earned 500 total points
ID: 38843309
You cannot do this through windows, but you should consider modals which imitates the behavior of your popup but is in the same dom as your main window.

Consider a jquery dialogue

Author Comment

ID: 38844768
Hmmmm.  Ok.  I've used jQuery dialogs before.  Basically they're just a div that gets its display mode  set to none or to  block and they're certainly in the same DOM as everything else in the viewport so the Drag and Drop should work fine.  

The dialog would have to have a form with an input type:file to get the images to upload, but that shouldn't be a problem.

I was following the path TinyMCE took with their Rich-text editor.  When you click the button  in the TinyMCE toolbar to insert an image a new popup window is opened that has  a form to get the image. The image is then transferred into the RTE window by calling a function back in the RTE window's  javascript with something like

Open in new window

But this inserts the image wherever the cursor is in the RTE window and I want to be able to drop it anywhere, so I wanted to employ Drag and Drop.

I'm wondering now why TinyMCE went to all the trouble of opening a new window, instead of using a dialog.

I gave you the points for your suggestion.  If you happen to have any thoughts on the above I'd  be interested.


Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Dropdowns 15 33
Access RV042 GUI / Browser Issues 25 52
html input 8 44
Binding a Grid in Javascript 5 46
In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question