views:

231

answers:

1

I'd like a user to be able to highlight a select of text and be able to drag and drop the text selection into a DIV. The DIV would be binded to be able to capture the text that was dropped.

Any ideas on how to make this happen?

Thanks

+1  A: 

Use Ben Alman's replaceText plugin to set a class on the highlighted text which will allow you to not only style it, but also link to be draggable by jQuery UI draggable to a div that you've predefined and set up with jQuery UI droppable. Once you've dropped the div inside there is an event you can bind to, and you'll be able to access the text inside of that.

lark
Links in respective order:http://jqueryui.com/demos/draggable/http://jqueryui.com/demos/droppable/http://jqueryui.com/demos/droppable/#event-drop
lark
I added the links properly!
Josh Stodola
Very interesting but how can you use Ben Alman's replaceText plugin to set a class on the highlighted text?
AnApprentice
When you say highlight do you mean actually taking the caret cursor and selecting the text. Or do you mean the text is highlighted with a background color and you can drag it into a DIV?
lark
If you are looking for the former, selecting text and getting the selection, there is yet another plugin to solve this:http://examplet.buss.hk/jquery/caret.php check out example #3
lark