I have a simple code that adds an image to #container when a button is clicked. The problem is that when I press the button first, the image size is not added properly. But when the button is pressed again, we get an added image with the correct image size. This does not happen if we remove resizable () from the equation.
Why the first click does not receive the correct image size. Code below:
<button id="test">add me</button>
<div id="container"></div>
<script type="text/javascript">
$('#test').live('click',function(){
var elm = '<img src="http://www.navegabem.com/blog/wp-content/uploads/2009/04/firefox-icon.png" />'
$(elm).appendTo('#container').resizable().parent().draggable();
});
</script>
source
share