jquery - appended element not draggable
Posted
by kikkoman90
on Stack Overflow
See other posts from Stack Overflow
or by kikkoman90
Published on 2010-04-21T08:54:34Z
Indexed on
2010/04/21
9:03 UTC
Read the original article
Hit count: 138
Hello,
So i have one div element that i append on my DOM with a click of a link. The problem is that i should be able to move that element around, but if i append it to my DOM i can't drag it at all.
So is the live()-function solution? If it is, how should i use it? I kinda don't know how. Here's the minimalistic code:
element to be appended (data.html):
<div id="menu">
<p>random stuff here</p>
</div>
jquery:
$("#menu").draggable();
$("#button").click(function(){
//custom function for exists()
if ($("#menu").exists()){
$("#menu").remove();
}
else {
$.get("data.html", function(data){
$("body").append(data);
});
}
});
© Stack Overflow or respective owner