jQuery wait for replaceWith to finish before executing -



jQuery wait for replaceWith to finish before executing -

i mass replace html in many divs replacewith. after replacing using jtruncate truncate texts. doesn't work, because @ time of execution, replacewith not done.

i tried callback trick (how extend jquery's replacewith function take callback function?) 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' }); }

ok, found solution post: jquery replacewith find new element

it seems after replace with, object removed dom, new 1 created. so, had alter code this:

$(".hotel_info").each(function () { var div; var div2; div = $(this); div2 = div.replacewithpush(data); truncinfo(div2);

});

$.fn.replacewithpush = function (a) { var $a = $(a); this.replacewith($a); homecoming $a;

};

thank time!

jquery replacewith

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -