Solved

Drag and Drop across Windows

Posted on 2013-02-01
2
316 Views
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.
0
Comment
Question by:steva
2 Comments
 
LVL 11

Accepted Solution

by:
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
0
 

Author Comment

by:steva
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
   
                                   
 window.opener.insertimg(n)

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.

Thanks
Steve
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now