So I'm about to hang up the gloves and give up, but before that I'm going to try StackOverflow. :)
What I'm trying to achieve:
I'm building an app where one of its functionalities is to create new DOM elements (mostly styled divs) and inject those elements in the current document. The injection is done via a 'drag and drop' functionality: user creates the div, drags it to the place where he wants it (other elements in the area 'get out of the way'), and releases it, thus fixing the div in the place where it was dropped. To give an example, it would be something like this: http://vimeo.com/54413541#t=0m42s
The problem:
With JQuery UI, I have been able to add all the drag and drop functionality. However, I cannot achieve the part of "other elements in the area 'get out of the way'". Now, this would be fairly easy if I could control the current/parent document. In such a case, I would simply use JQuery UI's sortable behavior. But the current/parent document is also created by the user (copy+pasting HTML, scrapping remote HTML, etc.). So, there is no way I can add JQuery's UI sortable behavior to HTML that can vary each time. So, in short, I want to take a newly-created element, drag it over arbitrary HTML, push other elements in the vicinity out of the way (mostly in vertical axis), and finally inject the newly-created element in the area when the user releases the mouse. Again: http://vimeo.com/54413541#t=0m42s
What I have tried:
I have tried all sorts of combination with JQuery's UI draggable, droppable, and sortable behaviors. The main obstacle here is that the HTML is arbitrary, so I cannot think "make this list of divs sortable", since I dont know if there will be a list of divs.
I also tried creating a placeholder div above the current hovered element, so that this placeholder 'makes space' for the dragged div. But this resulted in crappy behavior and very bad results.
Solutions in JQuery, JQueryUI, or a similar nifty library are preferred.