Reputation: 23
I am creating elements using:
$('#articleview').append(articles);
I need to apply the dotdotdot plugin to this dynamically created html
$(document).ready(function() {
$(".ellipsis").dotdotdot();
});
but it's not working in dynamically created html
Upvotes: 1
Views: 616
Reputation: 1396
After the $('#articleview').append(articles);
call -
$(".ellipsis").dotdotdot();
And this should work...
dotdotdot()
did it's work for first time the document was loaded. When you changed the content, it needed to be called again.
Upvotes: 1
Reputation: 22323
Always call plugins after dom ready other wise plugin unable to find markup and fail.
var articles='Lorem Ipsum is simply dummy text Lorem Ipsum is simply dummy text Lorem Ipsum is simply dummy text Lorem Ipsum is simply dummy text';
$('#wrapper').append(articles);
$(".ellipsis").dotdotdot();
#wrapper {
width: 100px;
height: 20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://dotdotdot.frebsite.nl/js/jquery.dotdotdot-1.2.1.js"></script>
<div id="wrapper" class='ellipsis'></div>
Upvotes: 0