Making div dragable after being inserted from database
Wondered if anyone could help me out with this jquery ui drag/drop issue.
I have some draggable and droppable divs that clone themselves when they are dragged over to there container. I am saving the position of the div's in a database, however if I insert the exact same HTML dynamicly and reload the page the div is no longer draggable, droppable etc.
I understand that its because the jQuery is no longer bound to the div...?
So my question, how can I enable the dynamicly inserted div's to be draggable/droppable again开发者_StackOverflow?
I did try and implement LiveQuery but could not get it working, how would I use .live?
Here's a URL to the page (link went dead) all the drag/drop etc JS is in custom.js
Any help is really appreciated
Many thanks
EDIT: Anyone have any ideas? I really am stuck on this one :(
you just need to call draggable()
on the items that are in your tree. Your existing code does this already for all items having the class drag
.
From your code ('custom.js'):
//Make element draggable
$(".drag").draggable( ... );
This doesn't affect the items in your tree, because they don't have the class drag
. An easy fix would be to simply add the class drag
to your tree items. Alternately, you could specifically select your tree items somehow, and then apply draggable to that selection.
精彩评论