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.
I tried the callback trick (How do I extend jQuery's replaceWith function to accept a callback function?) but didn't work.
Any ideas?
$(".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'
});
}