p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning JavaScript and CSS Development with jQuery (http://p2p.wrox.com/forumdisplay.php?f=502)
-   -   Drag and drop (http://p2p.wrox.com/showthread.php?t=75205)

davidkpham July 11th, 2009 05:57 PM

Drag and drop

I just bought this book, and I must say it is extremely helpful to me. Thank you for writing such a great book!

I just have a question - I know about all the drag and drop functionalities given to me by jQuery, but I need to have a way to create a drop area that can recognize text, images, or text and images that are not explicitly declared as a draggable. For example, I just want to highlight random text on a site whose code I have no control over, like say Yahoo.com, and drag it using browser dragging functionalities, and drop it into a box that I create, all while being able to access what was dropped, etc.

How can I do this? Any help would be greatly appreciated.

Thank you,

samjudson July 11th, 2009 06:12 PM

Someone correct me if I'm wrong but I don't believe that this is possible I'm afraid.

Firstly cross window drag and drop is only supported in certain browsers (i.e. Safari).

Secondly, for JQuery drag something it has to have the draggable method called on it - you're only going to be able to do this on pages you control and can load Jquery on I'm afraid (i.e. yahoo.com is a no go). There might be a use the select event to trigger the calling of the draggable method on whatever was selected, but I doubt it would be fool proof.

samjudson July 11th, 2009 06:13 PM

Further note: It sounds like what you are trying to do is more like an extension (or a web accelerator in IE). You might be better investigating that avenue.

davidkpham July 11th, 2009 06:43 PM

Hello Sam,

Thank you for the response. I hope I didn't confuse you - I don't want to do any cross browser drag-and-drop. I'm going to be creating a bookmarklet that will create a droppable area on the page on which users can drop text, images, or text and images into. I also know of a way to load jQuery pages I do not control.

Is there any way to do this kind of drag-and-drop?


samjudson July 11th, 2009 07:16 PM

There probably is yes. Images should be relatively simple, but text would be much harder, and as I said you would have to try to hook the select event up on every text element (or the body) and then try to work out what had been selected. I'm not sure if this is possible, at least not in a cross-browser compatible way.

davidkpham July 11th, 2009 08:45 PM

How can I hook up a select event on every text element? I had assumed the select event only worked on text in input elements.

samjudson July 12th, 2009 03:10 AM

Ah yes, good point. In that case I don't know what you might do I'm afraid.

All times are GMT -4. The time now is 03:16 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.