Hi everyone, I'm trying to make some divs draggable, and I managed to do this using jquery-ui. I also have a script that removes 2 divs and merges them into one (for example, if they were merged together), but when I call the drag function on a new "merged" div, I get an error - that’s the name .. So what is the problem ? how is it possible that the .draggable function works in one place and not in another (in the same file) !!
this is a drag and drop function:
function drag($class){
$("."+$class).draggable({
containment: ".tab-content",
grid: [ 3, 3 ],
zIndex:100,
obstacle: "#nothere",
preventCollision: true,
drag:
function(){
$(".test").css("background-color","red");
$(this).css("background-color","green");
}
});
}
I called it first for a test class that works fine without errors
drag("test");
but when I call it at another time inside the merge function, it returns an error: Uncaught TypeError: $ (...). Draggable is not a function
drag("test:not(.ui-draggable)");
js file loaded correctly:
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>