0

I have variable long html texts in a html object what have overflow: auto. I need to convert this text to pageable somehow. I tried to write my own jQuery plugin for this, but not working very well. There are solution to this?

netdjw
  • 5,419
  • 21
  • 88
  • 162
  • Have you checked this answer: http://stackoverflow.com/questions/7400174/continuing-overflowed-text-in-a-different-div ? – jtheman Oct 26 '12 at 08:04
  • yep, but there is not a ready solution for this problem. Anyway there is many good ideas. Thank you. – netdjw Oct 26 '12 at 08:18
  • Maybe do a modification of http://archive.plugins.jquery.com/project/pagination to split after certain length instead of # of items ? – jtheman Oct 26 '12 at 08:28
  • Hm, this is interesting, but my `

    ` elements has variable length. You give me an idea. Thanks.

    – netdjw Oct 26 '12 at 08:41

2 Answers2

2

I had this old bit of truncating code that I modified slightly to create pages... http://jsfiddle.net/3mQLG/ It's not 'plugin' format, but the function there is the crux of it. All you would need to do is add the css and paging controls.

Here is the heart of the loop that will shorten a block of text one word at time until it reaches a desired height. It could probably be tweaked for efficiency, but maybe it will give you some ideas.

    while (el.height() > maxHeight) {
        text = $.trim(el.text());
        newText = text.substring(0, text.lastIndexOf(" "));
        el.text($.trim(newText));
    }

Once the loop is done you throw the newText in a page and you do it all again with the remaining orignal text until there's none left.

brains911
  • 1,310
  • 7
  • 5
0

Do you mean a truncation plugin? This will cut off text after a specified number of characters and hide the rest, which can be viewed using a 'read more' link. This question has answers which show good plugins for this

Community
  • 1
  • 1
danwellman
  • 9,068
  • 8
  • 60
  • 88
  • truncation is not really the same as "pageable". If you read the subject you see he wants to "slice" the content. Also this is rather a comment but an answer. – jtheman Oct 26 '12 at 08:06
  • Not exactly. This all are read more-less solition. I need something what create pages from the long text with next-prev buttons. – netdjw Oct 26 '12 at 08:08