I am working on a project where I have a draggable element generated dynamically using jQuery. The div containing the element also has a background image. How can I ensure that the draggable element never goes outside of the boundaries of the div?
If you need to see the code, it can be found here: jsfiddle.net.
$(document).ready(function () {
$("button").click(function () {
$("#currentimage").append('<img id="dragable" src="http://s25.postimg.org/pi8ruls3z/image.jpg" width="200px" height="auto" />');
$("#dragable").draggable();
});
});