title: jQuery draggable element detaches from resizable parent after drag
body: <p>I have this:</p>
  
  <pre><code>&lt;style&gt;
  #pic_wrapper{
      display: block;
      position: relative;
      padding: 0;
  }
  #selected_picture img {
      width: 100%;
      height: auto;
  }
  .pin {
      display: none; 
      position: absolute; 
      height: 50px;
      width: 50px;
      padding: 0;
      margin: 0;
  }
  &lt;/style&gt;
  
  &lt;div id="pic_wrapper"&gt;
      &lt;div id="selected_picture"&gt;
          &lt;img src="map.png" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and append markers to the image with:</p>
  
  <pre><code>&lt;script type="text/javascript" charset="UTF-8"&gt;
  $(function(){
      $('#pic_wrapper').resizable();
  
      $('#selected_picture').on('click', function(e){
          x = ((e.offsetX) / $(this).width()) * 100 + "%";
          y = ((e.offsetY) / $(this).height()) * 100 + "%";
          var pin = $('&lt;div class="pin"&gt;&lt;img class="pin-img" src="&lt;?php echo $imgURL; ?&gt;pin.png" /&gt;&lt;/div&gt;');
          pin.uniqueId();
          $('#pic_wrapper').append(pin);
          pin.draggable({containment: 'parent'});
          pin.css('left', x).css('top', y).show();
  </code></pre>
  
  <p>I need to scale the #selected_picture together with all pins so that they remain at the same relative positions (points clicked on the image).</p>
  
  <p>The above works fine with resizing the wrapper with pins but only until any pin is dragged. After dragging the pins, they become detached from the parent and remain at fixed positions regardless of resizing the wrapper.</p>
  
  <p>How can I make them stick to the parent wrapper after dragging?</p>
  
  <p>See the Fiddle FYI: <a href="https://jsfiddle.net/linuxoid/9w4y2cyp/" rel="nofollow noreferrer">https://jsfiddle.net/linuxoid/9w4y2cyp/</a></p>
  
  <p>[SOLVED]</p>
  
  <p>After dragging stops the position is set in 'px', so in order to make it resizable again, I had to convert the 'px' to '%':</p>
  
  <pre><code>pin.on('dragstop', function(e){
      var $this = $(this);
      x = (($this.position().left) / $('#selected_picture').width()) * 100 + "%";
      y = (($this.position().top) / $('#selected_picture').height()) * 100 + "%";
      pin.css('left', x).css('top', y);
  });
  </code></pre>