title: jQuery wait for replaceWith to finish before executing
body: <p>I bulk replace html in many divs with replaceWith. After replacing I am using jTruncate to truncate the texts. However it doesn't work, because at the time of execution, replaceWith is not done.</p>
  
  <p>I tried the callback trick (<a href="https://stackoverflow.com/questions/9022986/how-do-i-extend-jquerys-replacewith-function-to-accept-a-callback-function">How do I extend jQuery&#39;s replaceWith function to accept a callback function?</a>) but didn't work.</p>
  
  <p>Any ideas?</p>
  
  <pre><code>$(".hotel_info").each(function () {
      var div;
      div = $(this);
      div.replaceWith(data);
      truncInfo(div);
  });
  
  function truncInfo(div) {
      div.jTruncate({
          length: 100,
          minTrail: 100,
          moreText: '[more...]',
          lessText: '[less...]',
          ellipsisText: '...',
          moreAni: 'fast',
          lessAni: 'fast'
      });
  }
  </code></pre>