Wednesday, November 5, 2014

To check if a div element was added to the page - jquery dotdotdot

I'd like to use the dotdotdot plugin - now, what i wouldn't like is to create all the links individually: $("#wrapper").dotdotdot() . i'd rather like to be able and listen for divs with the class 'textoverflow_dotdotdot' and then add the link automatically.
something like this:
$(document).on('DIV WAS ADDED','.textoverflow_dotdotdot', function(){
     $(this).dotdotdot();
}
any ideas?

Solution:
If we are using a jquery dotdotdot in ajax call following syntax should be used.

$(document).bind('ajaxSuccess', function(){
        $('.textoverflow_dotdotdot').removeClass('textoverflow_dotdotdot').addClass('dotters').change();

})

$(document).on('change','.dotters',function(){
           $(this).dotdotdot();
});