title: How to add draggable() with dynamic div being created inside loop?
body: <p>I am working on project. This is <a href="https://stackoverflow.com/questions/18789354/how-do-i-make-dynamically-created-elements-draggable">how do i make dynamically created elements draggable()?</a> 
  close but unable to solve it.</p>
  
  <p>I am creating a dynamic divs and now trying to place events that is draggable(). For example:</p>
  
  <pre><code>var div1 = '&lt;div class="orgchart"&gt;&lt;div class="o_diagram"&gt;';
  div1 += '&lt;div class="content"&gt;&lt;/div&gt; &lt;div class="org_chart_id"&gt;-1&lt;/div&gt;&lt;i class="edge verticalEdge bottomEdge fa"&gt;&lt;/i&gt;&lt;i class="fa fa-info-circle second-menu-icon"&gt;&lt;/i&gt;&lt;div class="second-menu"&gt;&lt;img class="avatar add_node" title="Add New Child" id="-1" src="/vuente_automation/static/src/img/add.png"/&gt;&lt;/div&gt;&lt;/div&gt;';
  //this is the loop which creates div and i am trying to add draggable events to them
  for (let key in edges){
              div1 += '&lt;div draggable="true" id="'+edges[key].destination+'" data-parent="1" class="node product-dept"&gt;&lt;div class="title"&gt;'+edges[key].destination+'&lt;/div&gt;&lt;div class="content"&gt;&lt;/div&gt;&lt;div class="org_chart_id"&gt;2&lt;/div&gt;&lt;i class="edge verticalEdge topEdge fa"&gt;&lt;/i&gt;&lt;i class="fa fa-info-circle second-menu-icon"&gt;&lt;/i&gt;&lt;div class="second-menu"&gt;&lt;img class="avatar add_node" title="Add New Child" id="'+edges[key].destination+'" src="/activity_workflow/static/src/img/add.png"&gt;&lt;img class="avatar edit_node" title="Edit Department" id="'+edges[key].destination+edges[key].destination+'" src="/activity_workflow/static/src/img/edit.png"&gt;&lt;img class="avatar delete_node" title="Delete Department" id="'+edges[key].destination+'" src="/activity_workflow/static/src/img/delete.png"&gt;&lt;/div&gt;&lt;/div&gt;';
  
              $(div1).appendTo('.o_diagram').draggable(); //not happening anything
  
   }
   div1 += '&lt;/div&gt; &lt;/div&gt;';
   var chart_vew = div1
   // move the renderered diagram to the widget's $el
   $div.contents().appendTo(this.$diagram_container.append(chart_vew));
  </code></pre>