Tiny jQuery plugin to truncate text with a knockout js binding handler.
$(".my-long-text").gutruncate();
$(".my-long-text").gutruncate({
minLength: 50,
readMoreText: "click me",
});
<p data-bind="gutruncate: myText"></p>
<p data-bind="gutruncate: { text: myText, options: { minLength: 10, readMoreText: 'click me' } }"></p>
- minLength - the minimum amount of text to display. default: 150
- tolerance - the amount of tolerance between the minLength and actual shown characters. default: 80
- readMoreText - the text to display on the show more link. default: "more"
- readLessText - the text to display on the show less link. default: "less"
- ellipsisText - the text to show for the ellipsis. default: "..."
- blockLevelMore - if true the read more link will be on a new line. default: true
- reapply - if set to true gutruncate will be deleted and recreated. default: false
- togglePosition - sets if the show/hide link should appear above (top) or below (bottom) the message. default: bottom
bower install gutruncate --save